{"id":43867,"library":"sqb","title":"SQB","description":"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.","status":"active","version":"3.9.2","language":"javascript","source_language":"en","source_url":"https://github.com/sqbjs/sqb","tags":["javascript","sql","query","builder","dialect","multi-dialect","database"],"install":[{"cmd":"npm install sqb","lang":"bash","label":"npm"},{"cmd":"yarn add sqb","lang":"bash","label":"yarn"},{"cmd":"pnpm add sqb","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default import works for ESM. For CommonJS, use const sqb = require('sqb').","wrong":"const sqb = require('sqb')","symbol":"sqb","correct":"import sqb from 'sqb'"},{"note":"Builder is a named export, not a default or deep import.","wrong":"import Builder from 'sqb/Builder'","symbol":"Builder","correct":"import { Builder } from 'sqb'"},{"note":"Dialect is a named export, also available via destructuring from require.","wrong":"const Dialect = require('sqb').Dialect","symbol":"Dialect","correct":"import { Dialect } from 'sqb'"}],"quickstart":{"code":"import sqb from 'sqb';\nimport { Dialect } from 'sqb';\n\n// Create a dialect for PostgreSQL\nconst dialect = new Dialect('postgresql');\n\n// Build a query\nconst query = sqb.select('id', 'name')\n  .from('users')\n  .where(sqb.eq('active', true))\n  .orderBy('name', 'asc')\n  .limit(10)\n  .build(dialect);\n\nconsole.log(query.sql);\n// Output: SELECT \"id\", \"name\" FROM \"users\" WHERE \"active\" = $1 ORDER BY \"name\" ASC LIMIT $2\nconsole.log(query.params);\n// Output: [true, 10]","lang":"typescript","description":"Shows how to build a simple SELECT query with a PostgreSQL dialect and obtain SQL and parameters."},"warnings":[{"fix":"Upgrade to v3.x and refactor code using the new API. Check migration guide.","message":"In version 3.0, the API was rewritten and many methods changed. For example, `sqb.select()` now returns a Query object, not a builder.","severity":"breaking","affected_versions":"<3.0"},{"fix":"Always pass a dialect to `build()`: `query.build(dialect)`.","message":"The `build()` method requires a dialect instance. Calling `build()` without a dialect will throw an error.","severity":"gotcha","affected_versions":">=3.0"},{"fix":"Use `import sqb from 'sqb'` (requires ESM) or set `\"type\": \"module\"` in package.json.","message":"Using `require('sqb')` in CommonJS is deprecated in favor of ES module imports. Future versions may drop CJS support.","severity":"deprecated","affected_versions":">=3.5"},{"fix":"Use the dialect's `formatParams` method to see how parameters will be represented.","message":"Parameter numbering in parameterized queries depends on the dialect. PostgreSQL uses $1, $2, etc., while MySQL uses ?.","severity":"gotcha","affected_versions":">=3.0"}],"env_vars":null,"search_vec":"'3.9.2':19 'across':29 'allow':57 'api':24 'architectur':56 'bug':75 'build':26 'builder':11,99 'cadenc':70 'code':94 'connect':14 'custom':58 'databas':13,31,104 'dialect':8,32,59,100,103 'differ':30 'differenti':81 'emphas':50 'extens':5,55 'featur':79 'fix':76 'focus':40 'footprint':89 'framework':15 'includ':82 'javascript':86,96 'key':80 'knex.js':48 'latest':85 'librari':64 'lightweight':88 'low':44 'memori':45 'minor':78 'moder':68 'modular':53 'mssql':37 'multi':7,102 'multi-dialect':6,101 'mysql':34 'node.js':17 'oracl':36 'perform':42 'postgresql':33 'power':92 'primarili':73 'provid':21 'queri':10,28,61,93,98 'releas':69 'scheme':95 'sqb':1,2,49 'sql':9,27,97 'sqlite':35 'standard':87 'support':83 'transform':62 'unifi':23 'unlik':47 'updat':72 'usag':46 'version':18","created_at":"2026-06-05T17:01:51.841203+00:00","updated_at":"2026-06-05T17:01:51.841203+00:00","problems":[{"fix":"Use `import sqb from 'sqb'` (default export) which has the `select` method.","cause":"Importing sqb incorrectly (e.g., using default import when named import is needed).","error":"TypeError: sqb.select is not a function"},{"fix":"Pass a dialect: `query.build(new Dialect('postgresql'))`.","cause":"Calling `query.build()` without passing a dialect instance.","error":"Error: No dialect provided"},{"fix":"Use a valid dialect name, e.g., 'postgresql' or 'mysql'. Check documentation for exact names.","cause":"The requested dialect name is not recognized. Supported dialects: 'postgresql', 'mysql', 'sqlite', 'oracle', 'mssql'.","error":"Dialect 'mysql' is not supported"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/sqbjs/sqb#readme","github":"https://github.com/sqbjs/sqb","docs":null,"changelog":null,"pypi":null,"npm":"sqb","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}