Skip to main content

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.

npm install @sqb/builder @sqb/connect @sqb/postgres postgrejs

Not sure which adapter you need? See Choosing a database adapter.

Optional packages​

# Versioned schema/data migrations (all supported databases)
npm install @sqb/migrator

# NestJS integration
npm install @sqb/nestjs
note

@sqb/migrator ships a migration adapter for every database SQB supports — PostgreSQL, MySQL, MariaDB, SQL Server, Oracle, and SQLite (both @sqb/sqlite and @sqb/sqljs). All seven adapter packages (and, through them, their drivers) are peer dependencies that @sqb/migrator imports eagerly, so npm 7+ installs the whole set alongside it. See Choosing a database adapter for the per-dialect differences.

Package versions​

Every @sqb/* package exports a version constant (since v6.0.10) holding its own package.json version, which is handy for diagnostics:

import { version } from '@sqb/connect';

console.log(version); // "6.1.1"

All packages in the monorepo are released together and share the same version number, so @sqb/builder, @sqb/connect, and every adapter you install should report the same value.