A TypeScript data structure for building SQL queries programmatically. Current version 2.2.2, updated regularly. It concatenates strings and objects to produce SQL strings, supporting MySQL and PostgreSQL parameter styles. Differentiates from ORMs by offering a lightweight, composable query builder without database access. Ships TypeScript types.
npm install knight-sqlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows building a SELECT query with JOIN and parameterized WHERE clause, then rendering to MySQL and PostgreSQL syntax.
Use sql.select(...).from(...)... each time, or wrap in a function.
Use `parameter(value)` to ensure value is parameterized and included in `values()`.
Render to one dialect per query instance; do not switch dialects on the same query object.
Use `parameter()` for value injection instead of custom objects.
For a LEFT JOIN, call `.join('left', 'table', 'alias', 'onClause')`.Use `import sql from 'knight-sql'` (no curly braces).
Use `import { parameter } from 'knight-sql'`.Ensure you have version 2.x and import the default export correctly.
No dependency data recorded yet.