{"id":43874,"library":"sql-bricks-postgres","title":"sql-bricks-postgres","description":"A lightweight, schemaless SQL generation library for PostgreSQL, built on top of sql-bricks. It adds PostgreSQL-specific features such as LIMIT/OFFSET, RETURNING, UPDATE...FROM, DELETE...USING, ON CONFLICT (UPSERT), and FROM VALUES. Version 0.6.0 is stable but sees infrequent releases. Key differentiator: provides a fluent API for generating parameterized SQL with PostgreSQL syntax, using $1, $2 placeholders for safe execution via database libraries. Designed for use with pg-bricks for query execution, but can be used standalone.","status":"active","version":"0.6.0","language":"javascript","source_language":"en","source_url":"https://github.com/Suor/sql-bricks-postgres","tags":["javascript","sql","generation","generate","query","pg","postgres","builder","select"],"install":[{"cmd":"npm install sql-bricks-postgres","lang":"bash","label":"npm"},{"cmd":"yarn add sql-bricks-postgres","lang":"bash","label":"yarn"},{"cmd":"pnpm add sql-bricks-postgres","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core SQL builder library extended by this package","package":"sql-bricks","optional":false}],"imports":[{"note":"CommonJS require returns the sql-bricks object directly, no default property.","wrong":"const sql = require('sql-bricks-postgres').default;","symbol":"default import (CommonJS)","correct":"const sql = require('sql-bricks-postgres');"},{"note":"ESM default import is the preferred modern approach.","wrong":"import * as sql from 'sql-bricks-postgres';","symbol":"default import (ESM)","correct":"import sql from 'sql-bricks-postgres';"}],"quickstart":{"code":"const sql = require('sql-bricks-postgres');\n// Select with parameterized query\nconst query = sql.select().from('user').where({name: 'Fred'}).toParams();\nconsole.log(query);\n// { text: 'SELECT * FROM \"user\" WHERE name = $1', values: ['Fred'] }\n\n// Insert with return\nconst insertQuery = sql.insert('user', {name: 'Alice', age: 30}).returning('id').toParams();\nconsole.log(insertQuery);\n// { text: 'INSERT INTO \"user\" (name, age) VALUES ($1, $2) RETURNING id', values: ['Alice', 30] }\n\n// Upsert\nconst upsertQuery = sql.insert('user', {name: 'Bob', age: 25})\n  .onConflict('name').doUpdate(['age']).toParams();\nconsole.log(upsertQuery);\n// { text: 'INSERT INTO \"user\" (name, age) VALUES ($1, $2) ON CONFLICT (name) DO UPDATE SET age = EXCLUDED.age', values: ['Bob', 25] }","lang":"javascript","description":"Demonstrates select, insert with RETURNING, and upsert (ON CONFLICT DO UPDATE) using parameterized queries."},"warnings":[{"fix":"Always call .toParams() and pass the {text, values} to your database driver.","message":"Never use .toString() to build SQL for execution; use .toParams() to get parameterized query safe from SQL injection.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Provide an array of columns to .doUpdate(columns) to avoid implicit behavior.","message":"The .onConflict().doUpdate() with no argument updates all columns automatically. This behavior may change; specify columns explicitly.","severity":"deprecated","affected_versions":"<0.7.0"}],"env_vars":null,"search_vec":"'0.6.0':41 '1':62 '2':63 'add':21 'api':53 'brick':3,19,77 'builder':93 'built':13 'conflict':35 'databas':69 'delet':32 'design':71 'differenti':49 'execut':67,80 'featur':25 'fluent':52 'generat':9,55,88,89 'infrequ':46 'javascript':86 'key':48 'librari':10,70 'lightweight':6 'limit/offset':28 'parameter':56 'pg':76,91 'pg-brick':75 'placehold':64 'postgr':4,92 'postgresql':12,23,59 'postgresql-specif':22 'provid':50 'queri':79,90 'releas':47 'return':29 'safe':66 'schemaless':7 'see':45 'select':94 'specif':24 'sql':2,8,18,57,87 'sql-brick':17 'sql-bricks-postgr':1 'stabl':43 'standalon':85 'syntax':60 'top':15 'updat':30 'upsert':36 'use':33,61,73,84 'valu':39 'version':40 'via':68","created_at":"2026-06-05T17:01:53.957398+00:00","updated_at":"2026-06-05T17:01:53.957398+00:00","problems":[{"fix":"Use: const sql = require('sql-bricks-postgres'); or import sql from 'sql-bricks-postgres';","cause":"Using import { sql } from 'sql-bricks-postgres' incorrectly; the default export is a function.","error":"TypeError: sql_bricks_postgres is not a function"},{"fix":"Run: npm install sql-bricks sql-bricks-postgres","cause":"sql-bricks-postgres depends on sql-bricks must be installed separately.","error":"Cannot find module 'sql-bricks'"}],"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/Suor/sql-bricks-postgres","github":"https://github.com/Suor/sql-bricks-postgres","docs":null,"changelog":null,"pypi":null,"npm":"sql-bricks-postgres","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}}