{"id":42570,"library":"cube-postgres-driver","title":"Cube.js Postgres Database Driver","description":"@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.","status":"active","version":"0.30.54","language":"javascript","source_language":"en","source_url":"https://github.com/cube-js/cube.js","tags":["javascript","typescript"],"install":[{"cmd":"npm install cube-postgres-driver","lang":"bash","label":"npm"},{"cmd":"yarn add cube-postgres-driver","lang":"bash","label":"yarn"},{"cmd":"pnpm add cube-postgres-driver","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for query orchestration and execution pipeline","package":"@cubejs-backend/query-orchestrator","optional":false},{"reason":"Underlying PostgreSQL client driver","package":"pg","optional":false}],"imports":[{"note":"Named export, not default. ESM only.","wrong":"import PostgresDriver from '@cubejs-backend/postgres-driver'","symbol":"PostgresDriver","correct":"import { PostgresDriver } from '@cubejs-backend/postgres-driver'"},{"note":"Factory function to instantiate driver with options.","wrong":"import { createPostgresDriver } from '@cubejs-backend/postgres-driver'","symbol":"createDriver","correct":"import { createDriver } from '@cubejs-backend/postgres-driver'"},{"note":"CommonJS require returns an object with PostgresDriver and createDriver.","symbol":"driver","correct":"const driver = require('@cubejs-backend/postgres-driver')"}],"quickstart":{"code":"import { PostgresDriver } from '@cubejs-backend/postgres-driver';\n\nconst driver = new PostgresDriver({\n  host: process.env.DB_HOST ?? 'localhost',\n  port: parseInt(process.env.DB_PORT ?? '5432'),\n  database: process.env.DB_NAME ?? 'myapp',\n  user: process.env.DB_USER ?? 'postgres',\n  password: process.env.DB_PASSWORD ?? '',\n});\n\nasync function testConnection() {\n  const result = await driver.query('SELECT 1 as test');\n  console.log(result);\n}\n\ntestConnection().catch(console.error);","lang":"typescript","description":"Instantiates PostgresDriver with environment variables and runs a simple test query."},"warnings":[{"fix":"Replace `import PostgresDriver from '...'` with `import { PostgresDriver } from '...'`","message":"Driver no longer uses default export in v0.10+. Must import named export `PostgresDriver`.","severity":"breaking","affected_versions":">=0.10.0"},{"fix":"Use `PostgresDriver` instead of `Driver`.","message":"`Driver` class renamed to `PostgresDriver` in v0.20. Old export still available but deprecated.","severity":"deprecated","affected_versions":"0.20.0 - 0.22.0"},{"fix":"Run `npm install pg` in your project.","message":"Driver uses `pg` module directly; ensure `pg` is installed as a peer dependency. Not bundled.","severity":"gotcha","affected_versions":">=0.10.0"},{"fix":"Set `maxPoolSize` or `timeout` option in constructor.","message":"Connection timeout defaults to 60 seconds; may cause long waits on misconfiguration.","severity":"gotcha","affected_versions":">=0.30.0"}],"env_vars":null,"search_vec":"'/postgres-driver':8 '0.30.54':29 '12':74 'acceler':69 'analyt':22,70 'api':23 'around':44 'backend':7 'cach':67 'compil':55 'configur':61 'connect':60 'cube.js':1,17,34,50,59 'cubej':6 'cubejs-backend':5 'current':25 'databas':3,14 'definit':79 'differenti':57 'driver':4,15 'generat':52 'javascript':12,80 'key':56 'modul':47 'monorepo':35 'month':37 'node.js':73 'open':20 'open-sourc':19 'optim':48 'parameter':64 'part':32 'pg':46 'platform':24 'postgr':2,13 'provid':40 'pure':11 'queri':51,65,71 'releas':30,38 'schema':54 'ship':76 'simplifi':58 'sourc':21 'stabl':26 'support':72 'thin':42 'type':78 'typescript':77,81 'use':63 'version':27 'wrapper':43","created_at":"2026-06-05T16:55:37.484669+00:00","updated_at":"2026-06-05T16:55:37.484669+00:00","problems":[{"fix":"Run `npm install @cubejs-backend/postgres-driver`","cause":"Package not installed or npm install failed","error":"Cannot find module '@cubejs-backend/postgres-driver'"},{"fix":"Change to `import { PostgresDriver } from '@cubejs-backend/postgres-driver'`","cause":"Using default import instead of named import","error":"TypeError: Driver is not a constructor"},{"fix":"Set `host` to the correct hostname or IP address, e.g., 'db' for docker-compose","cause":"PostgreSQL host not reachable (e.g., Docker container)","error":"Error: getaddrinfo ENOTFOUND localhost"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/cube-js/cube.js#readme","github":"https://github.com/cube-js/cube.js","docs":null,"changelog":null,"pypi":null,"npm":"cube-postgres-driver","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database","analytics"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}