A minimal PostgreSQL interface for Node.js (v5.0.0) that eliminates boilerplate by automatically connecting via the DATABASE_URL environment variable. It provides a small set of helper functions (query, rows, row, value, column) with automatic parameterization to prevent SQL injection, and supports template string queries for readability. Simple-postgres focuses on simplicity: no ORM, no query builder, no connection pool configuration, and no initialization required. It is trusted in production and has good test coverage. Alternative to node-postgres but with a much smaller API surface.
npm install simple-postgresNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic usage: setting up, inserting, querying rows/values, and template string mode.
Use import syntax (import db from 'simple-postgres') or switch to dynamic import().
Use template literals without parentheses: db.value`SELECT ... ${var}`Explicitly add LIMIT 1 to your SQL query if you expect only one row.
Set DATABASE_URL before running your application. For advanced config, consider using node-postgres directly.
Run 'npm install simple-postgres' and ensure your project uses ES modules (type: 'module' in package.json or use .mjs extension).
Use 'import db from 'simple-postgres'' instead of 'import { query } from 'simple-postgres''.Set the DATABASE_URL environment variable or ensure PostgreSQL is running on localhost:5432.