PostgreSQL Connection to the Actual Data Source
This page covers the two halves of a Cube.js + Superset stack: pointing Cube.js at your real PostgreSQL database, and installing Apache Superset in a Python virtual environment to visualize the data.
1. Point Cube.js at the Actual Database
Replace the in-memory demo data with your real PostgreSQL source by setting
these values in .env:
CUBEJS_DB_TYPE=postgres
CUBEJS_DB_HOST=localhost
CUBEJS_DB_PORT=5432
CUBEJS_DB_NAME=demodb
CUBEJS_DB_USER=postgres
CUBEJS_DB_PASS=password
CUBEJS_DB_SCHEMA=demodata
CUBEJS_DB_SCHEMAtells Cube.js which schema to read table metadata from — with the driver configured, tables from that schema appear in your data model.CUBEJS_DB_USER/CUBEJS_DB_PASSmust match a role that has read access to the target schema.
Start Cube.js with the new configuration:
npm run dev
2. Apache Superset Setup
Installation (inside a virtual environment)
python3 -m venv venv
source venv/bin/activate
Keep Superset isolated in this virtual environment, then install Superset and the PostgreSQL driver:
pip install apache-superset
pip install psycopg2-binary
superset db upgrade
superset fab create-admin # create the admin user
superset init
Once Superset runs, add a new database connection pointing at Cube.js's
PostgreSQL SQL API on port 15432 — see
Connecting
Cube.js to Superset (PostgreSQL SQL API) for the exact steps.