Lightweight PostgreSQL client for Node.js that loads SQL from files and uses named parameters with object binding. Current stable version is 7.0.1 (released 2023), maintained actively with monthly patches. Key differentiators: no SQL generation, supports named parameters via colon-prefixed syntax (e.g., :param), automatic parameter validation, transaction support with automatic commit/rollback, and TypeScript types. Requires peer dependency pg (^8.0.0). Ideal for teams that prefer writing raw SQL files over ORMs or query builders.
npm install tinypgNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Create a TinyPg instance using default env vars, run a parameterized query, and log results.
Use ESM imports (import or dynamic import()) or stick with tinypg 6.x if CommonJS needed.
Always use :param in SQL strings. Do not use $1 style placeholders.
Ensure the parameters object contains only the keys referenced in the SQL.
Use db.sql('file.key', params) for maintainable SQL files.Always use the transaction-specific database instance passed to the callback.
Run: npm install tinypg pg
Use import statement or switch to tinypg v6.x: npm install tinypg@6
Add the missing key to the parameters object or remove the placeholder from SQL.
Remove the unused key from the parameters object.