Installation
Query builder only
If all you need is to compose and serialize SQL — no driver, no network connection — install
just @sqb/builder:
npm install @sqb/builder
This is enough to build Select/Insert/Update/Delete statements and turn them into SQL
text. Dialect-specific behavior (pagination syntax, bind-parameter style, reserved-word quoting,
...) comes from a separate dialect plugin package — install and import the one matching your
target database before calling .generate({ dialect: '...' }):
npm install @sqb/postgres-dialect
import '@sqb/postgres-dialect'; // side-effect import — registers the 'postgres' dialect
import { Select } from '@sqb/builder';
Select('id').from('customers').limit(10).generate({ dialect: 'postgres' }).sql;
// select id from customers LIMIT 10
Without that import, .generate() still works, but silently falls back to generic,
dialect-neutral SQL (no error, just less precise output — for example, no LIMIT clause at all,
since pagination syntax is dialect-owned). See
The Dialect Plugin System for the full mechanism, and how
to write your own.
Builder + connection layer + adapter
For most projects — running queries against a real database, connection pooling, transactions,
and the ORM — install @sqb/builder, @sqb/connect, and exactly one database adapter. Each
adapter pulls in its matching driver as a peer dependency and its dialect package
automatically, so there's nothing else to wire up.
- PostgreSQL
- MySQL
- MariaDB
- SQL Server
- Oracle
- SQLite (native)
- SQLite (sql.js / WASM)
npm install @sqb/builder @sqb/connect @sqb/postgres postgrejs
npm install @sqb/builder @sqb/connect @sqb/mysql mysql2
npm install @sqb/builder @sqb/connect @sqb/mariadb mariadb
npm install @sqb/builder @sqb/connect @sqb/mssql mssql
npm install @sqb/builder @sqb/connect @sqb/oracle oracledb
npm install @sqb/builder @sqb/connect @sqb/sqlite
No separate driver package is needed — @sqb/sqlite uses Node's built-in node:sqlite (or
bun:sqlite under Bun). This requires Node.js >= 22.5.
npm install @sqb/builder @sqb/connect @sqb/sqljs sql.js
Use this instead of @sqb/sqlite when you need SQLite without native bindings — e.g. in the
browser or in a sandboxed runtime.
Not sure which adapter you need? See Choosing a database adapter.
Optional packages
# Versioned schema/data migrations (Postgres only today)
npm install @sqb/migrator
# NestJS integration
npm install @sqb/nestjs
@sqb/migrator currently only implements a Postgres migration adapter — running it against any
other dialect throws at runtime. See
Choosing a database adapter for details.