SQL builder library providing query builders independent of any database connection library. Current stable version is 5.0.1. It supports MySQL, PostgreSQL, and SQLite dialects, and uses prefix notation (Polish notation) for building complex queries. Key differentiators: provides SELECT, UPDATE, INSERT, DELETE, CREATE TABLE, and DROP TABLE operations; automatic quoting and escaping to prevent SQL injection; allows injecting custom quoter functions for database-specific quoting; does not handle query execution, only SQL generation. Release cadence is irregular; minor versions occasionally introduce breaking changes.
npm install sql-dialectNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows creating MySQL dialect, building SELECT with where condition, ordering, limit, and INSERT with set.
Use dialect.statement('select') to create statement objects.Migrate to dialect.statement('select') for all query types.Use array syntax with objects: [{ field: { '>': 5 } }] for comparisons.Set quoter option to null or a no-op function: new MySql({ quoter: s => s });Use a database connection library like 'pg', 'mysql2', or 'sqlite3' to run the SQL.
Replace dialect.select() with dialect.statement('select').Ensure you use dialect.statement('select') and then chain methods on the returned statement object.Use SQL operators as strings: { field: { '=': value } } or just { field: value } for equality.Use require('sql-dialect') and destructure PostgreSql from it.