Registry / database / sqb
library3.9.2jsnpmunverified

SQB is an extensible, multi-dialect SQL query builder and database connection framework for Node.js, version 3.9.2. It provides a unified API for building SQL queries across different database dialects (PostgreSQL, MySQL, SQLite, Oracle, MSSQL) with a focus on performance and low memory usage. Unlike knex.js, SQB emphasizes a more modular and extensible architecture, allowing custom dialects and query transformations. The library has had a moderate release cadence, with updates primarily for bug fixes and minor features. Key differentiators include support for latest JavaScript standards, lightweight footprint, and a powerful query coding scheme.

npm install sqb
INSTALL
IMPORT
SIG · SQB
S
sqb
databasejavascriptv3.9.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

sqb
import sqb from 'sqb'
const sqb = require('sqb')
Default import works for ESM. For CommonJS, use const sqb = require('sqb').
Builder
import { Builder } from 'sqb'
import Builder from 'sqb/Builder'
Builder is a named export, not a default or deep import.
Dialect
import { Dialect } from 'sqb'
const Dialect = require('sqb').Dialect
Dialect is a named export, also available via destructuring from require.

Shows how to build a simple SELECT query with a PostgreSQL dialect and obtain SQL and parameters.

import sqb from 'sqb'; import { Dialect } from 'sqb'; // Create a dialect for PostgreSQL const dialect = new Dialect('postgresql'); // Build a query const query = sqb.select('id', 'name') .from('users') .where(sqb.eq('active', true)) .orderBy('name', 'asc') .limit(10) .build(dialect); console.log(query.sql); // Output: SELECT "id", "name" FROM "users" WHERE "active" = $1 ORDER BY "name" ASC LIMIT $2 console.log(query.params); // Output: [true, 10]
Debug
Known issues
breakingIn version 3.0, the API was rewritten and many methods changed. For example, `sqb.select()` now returns a Query object, not a builder.
fix
Upgrade to v3.x and refactor code using the new API. Check migration guide.
affects: <3.0
gotchaThe `build()` method requires a dialect instance. Calling `build()` without a dialect will throw an error.
fix
Always pass a dialect to `build()`: `query.build(dialect)`.
affects: >=3.0
deprecatedUsing `require('sqb')` in CommonJS is deprecated in favor of ES module imports. Future versions may drop CJS support.
fix
Use `import sqb from 'sqb'` (requires ESM) or set `"type": "module"` in package.json.
affects: >=3.5
gotchaParameter numbering in parameterized queries depends on the dialect. PostgreSQL uses $1, $2, etc., while MySQL uses ?.
fix
Use the dialect's `formatParams` method to see how parameters will be represented.
affects: >=3.0
Errors
Common errors & fixes
TypeError: sqb.select is not a function
Importing sqb incorrectly (e.g., using default import when named import is needed).
fix
Use `import sqb from 'sqb'` (default export) which has the `select` method.
Error: No dialect provided
Calling `query.build()` without passing a dialect instance.
fix
Pass a dialect: `query.build(new Dialect('postgresql'))`.
Dialect 'mysql' is not supported
The requested dialect name is not recognized. Supported dialects: 'postgresql', 'mysql', 'sqlite', 'oracle', 'mssql'.
fix
Use a valid dialect name, e.g., 'postgresql' or 'mysql'. Check documentation for exact names.
Upgrade
Version history
3.9.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
20 hits · last 30 days
node
16
Meta
2
Amazon
1
OpenAI (training)
1
Resources
packagesqb
sqb — npm install sqb · libregistry