Registry / database / cube-postgres-driver

cube-postgres-driver

JSON →
library0.30.54jsnpmunverified

@cubejs-backend/postgres-driver is a pure JavaScript Postgres database driver for Cube.js, an open-source analytical API platform. Current stable version is 0.30.54, released as part of Cube.js monorepo with monthly releases. It provides a thin wrapper around the `pg` module optimized for Cube.js query generation and schema compilation. Key differentiator: simplifies Cube.js connection configuration and uses parameterized queries with caching for accelerated analytics queries. Supports Node.js >=12 and ships TypeScript type definitions.

npm install cube-postgres-driver
INSTALL
IMPORT
SIG · CUBE-POSTGRES-DRIV
C
cube-postgres-driver
databasejavascriptv0.30.54
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.

PostgresDriver
import { PostgresDriver } from '@cubejs-backend/postgres-driver'
import PostgresDriver from '@cubejs-backend/postgres-driver'
Named export, not default. ESM only.
createDriver
import { createDriver } from '@cubejs-backend/postgres-driver'
import { createPostgresDriver } from '@cubejs-backend/postgres-driver'
Factory function to instantiate driver with options.
driver
const driver = require('@cubejs-backend/postgres-driver')
CommonJS require returns an object with PostgresDriver and createDriver.

Instantiates PostgresDriver with environment variables and runs a simple test query.

import { PostgresDriver } from '@cubejs-backend/postgres-driver'; const driver = new PostgresDriver({ host: process.env.DB_HOST ?? 'localhost', port: parseInt(process.env.DB_PORT ?? '5432'), database: process.env.DB_NAME ?? 'myapp', user: process.env.DB_USER ?? 'postgres', password: process.env.DB_PASSWORD ?? '', }); async function testConnection() { const result = await driver.query('SELECT 1 as test'); console.log(result); } testConnection().catch(console.error);
Debug
Known issues
breakingDriver no longer uses default export in v0.10+. Must import named export `PostgresDriver`.
fix
Replace `import PostgresDriver from '...'` with `import { PostgresDriver } from '...'`
affects: >=0.10.0
deprecated`Driver` class renamed to `PostgresDriver` in v0.20. Old export still available but deprecated.
fix
Use `PostgresDriver` instead of `Driver`.
affects: 0.20.0 - 0.22.0
gotchaDriver uses `pg` module directly; ensure `pg` is installed as a peer dependency. Not bundled.
fix
Run `npm install pg` in your project.
affects: >=0.10.0
gotchaConnection timeout defaults to 60 seconds; may cause long waits on misconfiguration.
fix
Set `maxPoolSize` or `timeout` option in constructor.
affects: >=0.30.0
Errors
Common errors & fixes
Cannot find module '@cubejs-backend/postgres-driver'
Package not installed or npm install failed
fix
Run `npm install @cubejs-backend/postgres-driver`
TypeError: Driver is not a constructor
Using default import instead of named import
fix
Change to `import { PostgresDriver } from '@cubejs-backend/postgres-driver'`
Error: getaddrinfo ENOTFOUND localhost
PostgreSQL host not reachable (e.g., Docker container)
fix
Set `host` to the correct hostname or IP address, e.g., 'db' for docker-compose
Upgrade
Version history
0.30.54latest on npm
Audit
Dependencies
@cubejs-backend/query-orchestratorrequiredRequired for query orchestration and execution pipeline
pgrequiredUnderlying PostgreSQL client driver
Agent activity
36 hits · last 30 days
node
28
OpenAI (training)
1
Resources
cube-postgres-driver — npm install cube-postgres-driver · libregistry