Sprintf-style PostgreSQL query escaping and formatting library for Node.js. Current stable version 0.2.0 (released 2012, no updates since). Offers %s, %L, %I, %Q format specifiers for strings, literals, identifiers, and dollar-quoted strings. Unlike parameterized queries (which keep queries safe), this escapes inline into SQL strings, suitable for dynamic query construction where parameters cannot be used. Works in Node.js only.
npm install pg-escapeNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic sprintf-style formatting with %I (identifier), %L (literal), %s (simple string), and %Q (dollar-quoted string).
Use %L for SQL NULL literal; check for null separately.
Sanitize identifiers before using %I or avoid user input.
Prefer pg's parameterized queries ($1, $2) over inline escaping.
Consider using pg-promise or sql-template-strings for active alternatives.
Change to const escape = require('pg-escape');Ensure identifier values are strings; check for null before formatting.
Use %L for literal values to properly escape single quotes and backslashes.
No dependency data recorded yet.