{"id":17192,"library":"cubejs-tiva-postgres-driver","title":"Cube.js Tiva Postgres Driver","description":"The `cubejs-tiva-postgres-driver` package is a pure JavaScript PostgreSQL database driver specifically designed for the Cube.js analytics API platform. It is a fork of the official Cube.js PostgreSQL driver, currently at version `0.0.7`. This driver enables a Cube.js backend to connect and query PostgreSQL databases. Due to its status as a fork and early version number, it likely has an irregular release cadence dictated by the needs of its maintainers rather than a public schedule. Key differentiators include its \"pure JavaScript\" implementation for PostgreSQL connectivity within Cube.js, and potential custom modifications unique to the \"Tiva\" project. It targets Node.js environments from version 14.0.0 upwards and ships with TypeScript type definitions for improved developer experience.","status":"maintenance","version":"0.0.7","language":"javascript","source_language":"en","source_url":"https://github.com/sajdre/cube","tags":["javascript","typescript"],"install":[{"cmd":"npm install cubejs-tiva-postgres-driver","lang":"bash","label":"npm"},{"cmd":"yarn add cubejs-tiva-postgres-driver","lang":"bash","label":"yarn"},{"cmd":"pnpm add cubejs-tiva-postgres-driver","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Runtime dependency for connecting to PostgreSQL databases, inherited from the official Cube.js Postgres driver.","package":"pg","optional":false}],"imports":[{"note":"This package is primarily designed for ESM consumption in Node.js 14+ environments. While CJS usage might be possible via bundlers, direct `require()` is not the recommended or typical pattern.","wrong":"const { PostgresDriver } = require('cubejs-tiva-postgres-driver');","symbol":"PostgresDriver","correct":"import { PostgresDriver } from 'cubejs-tiva-postgres-driver';"},{"note":"Recommended for type-checking and autocompletion when defining the driver's configuration object within your Cube.js setup. The exact type name might be `DriverConfig` or `PostgresOptions` depending on the fork's specific API.","wrong":"import { PostgresDriverOptions } from 'cubejs-tiva-postgres-driver';","symbol":"PostgresDriverOptions","correct":"import type { PostgresDriverOptions } from 'cubejs-tiva-postgres-driver';"},{"note":"This pattern imports all named exports into a namespace object, allowing access via `TivaPostgres.PostgresDriver` etc. Useful for inspecting available exports or consolidating references.","wrong":"const TivaPostgres = require('cubejs-tiva-postgres-driver');","symbol":"* as TivaPostgres","correct":"import * as TivaPostgres from 'cubejs-tiva-postgres-driver';"}],"quickstart":{"code":"import { CubejsServer } from '@cubejs-backend/server';\nimport { PostgresDriver } from 'cubejs-tiva-postgres-driver';\n\nconst server = new CubejsServer({\n  // Replace with your Cube.js configuration, e.g., queryRewrite, externalRefresh\n  // For full configuration options, refer to the Cube.js documentation.\n  \n  driverFactory: (context) => {\n    // The context object can be used to pass dynamic information if needed.\n    console.log('Initializing Tiva Postgres Driver for Cube.js context:', context);\n    return new PostgresDriver({\n      host: process.env.DB_HOST ?? 'localhost',\n      port: parseInt(process.env.DB_PORT ?? '5432', 10),\n      user: process.env.DB_USER ?? 'cube',\n      password: process.env.DB_PASSWORD ?? 'password',\n      database: process.env.DB_NAME ?? 'cube_db',\n      ssl: process.env.DB_SSL === 'true', // Set DB_SSL to 'true' for SSL connection\n    });\n  },\n  // Additional Cube.js options can go here, e.g., `apiSecret`, `schemaPath`\n});\n\nserver.listen().then(({ app, port }) => {\n  console.log(`🚀 Cube.js server is listening on http://localhost:${port}`);\n  console.log('Access your Cube.js playground at /cubejs-api');\n});","lang":"typescript","description":"Demonstrates how to integrate the `cubejs-tiva-postgres-driver` into a basic Cube.js backend configuration using environment variables for database credentials and enabling SSL."},"warnings":[{"fix":"Consider using the official `@cubejs-backend/postgres-driver` for stable and maintained functionality, unless specific modifications in this fork are critical for your project.","message":"This package is a fork of the official Cube.js Postgres driver. It may not receive timely updates, bug fixes, or security patches from the Cube.js core team. Features and API might diverge from the official driver over time.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Thoroughly test in your specific environment and review the source code for stability before deploying to production. Be prepared for potential breaking changes in minor versions.","message":"The package is currently at version `0.0.7`, indicating an early development stage or usage specific to a particular project. It might not be production-ready for general use and could experience frequent API changes without major version bumps.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Ensure your Node.js environment is updated to a compatible version (14.x, 16.x, or 17.x and above) to meet the engine requirements specified in `package.json`.","message":"This driver explicitly requires Node.js versions `^14.0.0 || ^16.0.0 || >=17.0.0`. Attempting to use older Node.js runtimes will result in compatibility errors during installation or runtime.","severity":"breaking","affected_versions":">=0.0.1"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Upgrade your Node.js environment to version 14.x, 16.x, or 17.x or newer.","cause":"The installed Node.js version does not meet the minimum requirements specified in the package's `engines` field.","error":"Error: The package 'cubejs-tiva-postgres-driver' is not compatible with your current Node.js version. Required: ^14.0.0 || ^16.0.0 || >=17.0.0. Found: v12.x.x"},{"fix":"Ensure all essential PostgreSQL connection options are passed as properties of an object to the `new PostgresDriver()` call, typically via environment variables (e.g., `process.env.DB_HOST`) or a configuration file.","cause":"The `driverFactory` function within your `cube.js` configuration is not providing all necessary database connection parameters (e.g., host, port, user, password, database) to the `PostgresDriver` constructor.","error":"TypeError: Cannot read properties of undefined (reading 'host') OR Error: Missing required connection option: host"},{"fix":"Ensure your Cube.js configuration file (e.g., `cube.js`) is treated as an ESM module by either using a `.mjs` file extension, or by adding `\"type\": \"module\"` to your `package.json` file. Alternatively, if feasible, use dynamic `import()` or stick to CJS `require()` if the package provides a CJS entry point.","cause":"You are attempting to use ECMAScript Modules (ESM) `import` syntax in a file that is being interpreted as a CommonJS (CJS) module, or in an older Node.js environment that doesn't fully support ESM.","error":"SyntaxError: Cannot use import statement outside a module"}],"ecosystem":"npm","meta_description":null}