Registry / database / db-conn-pgsql

db-conn-pgsql

JSON →
library1.6.2jsnpmunverified

PostgreSQL implementation of the db-conn JDBC-like interface for Node.js. Version 1.6.2 provides connection and pooling for PostgreSQL databases with TypeScript type definitions. This package implements the generic db-conn abstraction, making it easy to switch between database types. Release cadence is irregular; key differentiator is adherence to the db-conn interface specification. Active development status.

npm install db-conn-pgsql
INSTALL
IMPORT
SIG · DB-CONN-PGSQL
D
db-conn-pgsql
databasejavascriptv1.6.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PgsqlConnection
import { PgsqlConnection } from 'db-conn-pgsql'
const { PgsqlConnection } = require('db-conn-pgsql')
ESM import is recommended for TypeScript support; CommonJS require may not resolve types properly.
PgsqlConnectionPool
import { PgsqlConnectionPool } from 'db-conn-pgsql'
import { ConnectionPool } from 'db-conn-pgsql'
The pool class is named specifically 'PgsqlConnectionPool' to avoid naming conflicts.
createConnection
import { createConnection } from 'db-conn-pgsql'
import createConnection from 'db-conn-pgsql'
This is a named export, not default.

Shows how to create a PostgreSQL connection, execute a parameterized query, and close the connection properly.

import { createConnection } from 'db-conn-pgsql'; const conn = await createConnection({ host: 'localhost', port: 5432, user: 'user', password: process.env.PGPASSWORD ?? '', database: 'mydb' }); try { const result = await conn.execute('SELECT * FROM users WHERE id = $1', [1]); console.log(result.rows); } finally { await conn.close(); }
Debug
Known issues
breakingIn version 1.x, the 'execute' method now returns an object with 'rows' and 'fields' properties instead of just an array of rows.
fix
Update code to access 'result.rows' instead of the result directly.
affects: >=1.0.0
deprecatedThe 'query' method is deprecated; use 'execute' instead.
fix
Replace conn.query(...) with conn.execute(...).
affects: >=1.5.0
gotchaConnection strings must include the protocol; 'postgres://' prefix is required, not 'postgresql://' or just hostname.
fix
Use 'postgres://user:pass@host:port/db' format.
affects: >=1.0.0
gotchaPool connections are not automatically closed on process exit; must call pool.end() to avoid hanging connections.
fix
Call pool.end() before process exit or use SIGTERM handler.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'db-conn'
Missing peer dependency 'db-conn'
fix
Install the peer dependency: npm install db-conn
error: password authentication failed for user "..."
Incorrect credentials or missing pg_hba.conf configuration
fix
Verify username and password, and ensure pg_hba.conf allows password authentication.
TypeError: conn.execute is not a function
Using an older version of db-conn-pgsql that does not have execute method
fix
Upgrade to version 1.5.0 or later: npm install db-conn-pgsql@latest
Upgrade
Version history
1.6.2latest on npm
Audit
Dependencies
db-connrequiredProvides the base interface and types that db-conn-pgsql implements
pgrequiredUnderlying PostgreSQL driver used for actual database connections
Agent activity
9 hits · last 30 days
node
8
Resources
db-conn-pgsql — npm install db-conn-pgsql · libregistry