sql-statement is a tiny, tree-shakeable SQL statement builder (v1.1.0, last updated 2025) that safely escapes identifiers and values using placeholders (? for values, ?? for identifiers). Unlike ORMs or full query builders, it provides minimal abstraction: you write raw SQL fragments and use append, appendList, and appendPairs to compose queries. Ships TypeScript definitions and supports MySQL, PostgreSQL, and SQLite quoting styles via named exports (mysql, Pg, Sqlite). No database connectivity — generates final SQL strings for use with any driver. Release cadence is low; package is stable and lightweight (no dependencies).
npm install sql-statementNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic usage: instantiating a MySQL-dialect SQL builder, appending a query with placeholders, and converting to final string.
Import the dialect: import { mysql as SQL } from 'sql-statement'Always use '??' for column/table names and '?' for values. Example: sql.append('SELECT ?? FROM ?? WHERE ?', 'name', 'users', {id: 1})Explicitly pass separator: sql.appendPairs('?? = ?', obj, ' AND ')Change import to: import { mysql as SQL } from 'sql-statement'Ensure the number of placeholders matches the number of arguments after the SQL string.
Use placeholders instead: sql.append('SELECT * FROM users WHERE name = ?', name)No dependency data recorded yet.