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 (Postgres only today)
npm install @sqb/migrator

# NestJS integration
npm install @sqb/nestjs
note

@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.