Lightweight query string formatter for PostgreSQL in Node.js (v0.0.5, last updated 2014). Provides a printf-like syntax for safely building SQL queries with escaping for identifiers, literals, and subqueries. Supports parameterized queries via toParam() for use with node-postgres. Currently in maintenance mode; no updates since 2014. Alternative libraries like pg-promise, squel, or knex may be more actively maintained.
npm install pg-query-formatterNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic construction, parameterized output, array expansion, and Query.List for dynamic SQL building.
Migrate to a maintained library like pg-promise (https://github.com/vitaly-t/pg-promise) or knex (https://knexjs.org).
Always use new Query(fmt, ...values).
Use %L for literals and %I for identifiers to safely escape input. Avoid %s with user-supplied data.
Always call .toString() or .toParam() to get the formatted output.
Use const Query = require('pg-query-formatter'); and then new Query(...);Ensure you use new Query(fmt, ...).
Pass a string format as first argument: new Query('SELECT %L', value);No dependency data recorded yet.