SQB is a TypeScript database framework for Node.js: a query builder, connection pooling, an ORM and migrations for PostgreSQL, MySQL, MariaDB, SQL Server, Oracle and SQLite.
📖 Documentation · 🚀 Getting Started · 📦 Packages · 💬 Issues
SQB gives you a query builder, connection pooling, an ORM and migrations as one TypeScript toolkit. Queries are plain objects that SQB turns into the right SQL for the database you connect to, so the same code runs on every supported database.
Install the query builder, the connection layer and one database adapter:
npm install @sqb/builder @sqb/connect @sqb/postgresimport '@sqb/postgres';
import { Eq, Select } from '@sqb/builder';
import { SqbClient } from '@sqb/connect';
const client = new SqbClient({ dialect: 'postgres', host: 'localhost', database: 'mydb' });
const result = await client.execute(
Select('id', 'given_name').from('customers').where(Eq('active', true)).limit(10),
);
console.log(result.rows);To read and write typed entities through repositories instead, see the ORM guide. The full documentation is at sqbjs.org.
Most projects need @sqb/builder, @sqb/connect and one database adapter.
| Package | Description |
|---|---|
@sqb/builder |
The query builder: SQL statements as objects, serialized for any dialect. |
@sqb/connect |
Connection pooling, transactions, cursors and the ORM (entities, repositories). |
@sqb/migrator |
A versioned schema and data migration runner. |
@sqb/nestjs |
A NestJS module that provides an @sqb/connect client. |
@sqb/adapter-tests |
The conformance test suite every adapter runs. |
| Database | Adapter | Driver |
|---|---|---|
| PostgreSQL | @sqb/postgres |
postgrejs |
| MySQL | @sqb/mysql |
mysql2 |
| MariaDB | @sqb/mariadb |
mariadb |
| Microsoft SQL Server | @sqb/mssql |
mssql |
| Oracle Database | @sqb/oracle |
oracledb |
| SQLite | @sqb/sqlite |
node:sqlite / bun:sqlite |
| SQLite (WebAssembly) | @sqb/sqljs |
sql.js |
Each adapter loads its -dialect package, which holds that database's SQL syntax. Depend on a
-dialect package directly only to generate SQL without connecting.
Node.js 22 or later. @sqb/sqlite needs Node.js 22.5 or later, the first release with
node:sqlite.
Report bugs and discuss features on the GitHub issues page.
SQB is available under the BSD 3-Clause license.
