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

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.

Related Articles

A.M. Rinas

Written by A.M. Rinas

Full-Stack Software Engineer working on web applications, DevOps automation, and databases. More about me on the about page, or say hi through the contact page and LinkedIn.

← Back to all articles