Registry / database / any-db-postgres

any-db-postgres

JSON →
library2.3.0jsnpmunverified

PostgreSQL adapter for the Any-DB abstraction layer, version 2.3.0. Provides a uniform interface for PostgreSQL connections and queries that conform to the Any-DB API, allowing application code to be portable across different databases by swapping adapters. Relies on the pg.js driver and extends pg.Client and QueryStream for PostgreSQL-specific features. Note: the adapter is explicitly designed to be used as part of the any-db ecosystem and should not be used standalone; it requires the any-db package as a peer dependency.

npm install any-db-postgres
INSTALL
IMPORT
SIG · ANY-DB-POSTGRES
A
any-db-postgres
databasejavascriptv2.3.0
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.

createConnection
import { createConnection } from 'any-db-postgres'
const createConnection = require('any-db-postgres')
ESM import recommended; CommonJS require also works but may not be tree-shakable.
default export
import anyDBPostgres from 'any-db-postgres'
const anyDBPostgres = require('any-db-postgres')
Package has both default and named exports. Default export is the adapter object.
Connection
import { Connection } from 'any-db'
import { Connection } from 'any-db-postgres'
Connection type is re-exported from any-db, not from the adapter.

Creates a connection pool using the any-db-postgres adapter and runs a simple query.

import { createConnection } from 'any-db-postgres'; import { createPool } from 'any-db'; const pool = createPool(createConnection, { url: 'postgres://user:password@localhost:5432/dbname' }); pool.query('SELECT 1 AS num', (err, result) => { if (err) throw err; console.log(result.rows[0].num); // 1 pool.close(); });
Debug
Known issues
deprecatedThe any-db project is no longer actively maintained; use direct pg library for new projects.
fix
Migrate to the 'pg' package directly and remove any-db dependency.
affects: >=2.0
gotchaThe adapter's default export is the createConnection function, but the named export createConnection is also available; using default import may lead to confusion.
fix
Use named import: import { createConnection } from 'any-db-postgres'
affects: >=2.0
gotchaThis adapter relies on the pg.js (not pg) driver. If you have both pg and pg.js installed, ensure the correct one is used.
fix
Uninstall 'pg' if not needed, and install 'pg.js' as a dependency.
affects: >=2.0
breakingAs of v2.0, the adapter no longer supports callbacks for pool.query; use promises or explicit callback patterns.
fix
Update code to use promises: pool.query('SELECT 1').then(...).catch(...)
affects: >=2.0
Errors
Common errors & fixes
Error: Cannot find module 'any-db'
Missing peer dependency any-db
fix
npm install any-db
TypeError: createConnection is not a function
Incorrect import: using default import instead of named import
fix
Use import { createConnection } from 'any-db-postgres'
Error: The 'url' property is required for creating a pool
Missing url configuration for the pool
fix
Provide { url: 'postgres://...' } in the pool options
Upgrade
Version history
2.3.0latest on npm
Audit
Dependencies
any-dbrequiredpeer dependency required to use the adapter
Agent activity
16 hits · last 30 days
node
14
OpenAI (training)
1
Resources
any-db-postgres — npm install any-db-postgres · libregistry