SQL query string builder for Node.js supporting PostgreSQL, MySQL, MSSQL, Oracle, and SQLite. Current version 0.78.0 (as of 2019). Queries are parameterized by default to prevent SQL injection. Tables are defined in JavaScript, and query building is composable and chainable. Differentiates from other query builders by its simple API and support for multiple dialects with a single unified interface. Last stable release was over 5 years ago; the project appears to be in maintenance mode with no recent commits.
npm install sqlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Defines a table, builds a SELECT query with WHERE, OR, ORDER BY, and outputs parameterized text and values.
Call sql.setDialect('mysql') at the start of your app if you use MySQL.Replace `table.toKeyword()` with `toQuery().text` and `table.toParameter(column)` with parameterized `toQuery().values`.
Ensure column names in `columns` array or object match exactly with property accessed.
Always specify `.on(condition)` after `.join()` or `.leftJoin()`.
Update table definitions to use `columns` array instead of `properties`.
Use the `text` property directly; append semicolon if required by your database driver.
Ensure that you have defined the table with sql.define() and that the query chain is complete (e.g., .from(table) called).
Verify that `const user = sql.define({...})` is called correctly and that you are using ES module import or CommonJS require correctly.Add `import sql from 'sql'` (ESM) or `const sql = require('sql')` (CommonJS) at the top of your file.Use one of: 'postgres', 'mysql', 'mssql', 'sqlite' or install a dialect plugin (if available).