Skip to main content

Synchronization tool for dbt models to Cube.js schemas and BI tools

Project description

dbt-cube-sync

A powerful synchronization tool that creates a seamless pipeline from dbt models to Cube.js schemas and BI tools (Superset, Tableau, PowerBI).

Features

  • ๐Ÿ”„ dbt โ†’ Cube.js: Auto-generate Cube.js schemas from dbt models with metrics
  • ๐Ÿ—ƒ๏ธ Flexible Data Type Source: Get column types from catalog OR directly from database via SQLAlchemy
  • ๐ŸŽฏ Model Filtering: Process specific models instead of all models
  • ๐Ÿ“Š Cube.js โ†’ BI Tools: Sync schemas to multiple BI platforms
  • ๐Ÿ—๏ธ Extensible Architecture: Plugin-based connector system for easy BI tool integration
  • ๐Ÿณ Docker Support: Containerized execution with orchestration support
  • ๐ŸŽฏ CLI Interface: Simple command-line tools for automation

Supported BI Tools

  • โœ… Apache Superset - Full implementation
  • ๐Ÿšง Tableau - Placeholder (coming soon)
  • ๐Ÿšง PowerBI - Placeholder (coming soon)

Installation

Using Poetry (Development)

cd dbt-cube-sync
poetry install
poetry run dbt-cube-sync --help

Database Drivers (for SQLAlchemy URI feature)

If you want to use the --sqlalchemy-uri option to fetch column types directly from your database, you'll need to install the appropriate database driver:

# PostgreSQL
poetry add psycopg2-binary

# MySQL
poetry add pymysql

# Snowflake
poetry add snowflake-sqlalchemy

# BigQuery
poetry add sqlalchemy-bigquery

# Redshift
poetry add sqlalchemy-redshift

Using Docker

docker build -t dbt-cube-sync .
docker run --rm dbt-cube-sync --help

Quick Start

1. Generate Cube.js Schemas from dbt

Option A: Using catalog file (traditional method)

dbt-cube-sync dbt-to-cube \
  --manifest ./target/manifest.json \
  --catalog ./target/catalog.json \
  --output ./cube_output

Option B: Using database connection (no catalog needed)

dbt-cube-sync dbt-to-cube \
  --manifest ./target/manifest.json \
  --sqlalchemy-uri postgresql://user:password@localhost:5432/mydb \
  --output ./cube_output

Option C: Filter specific models

dbt-cube-sync dbt-to-cube \
  --manifest ./target/manifest.json \
  --sqlalchemy-uri postgresql://user:password@localhost:5432/mydb \
  --models orders,customers,products \
  --output ./cube_output

2. Sync to BI Tool (Optional)

# Sync to Superset
dbt-cube-sync cube-to-bi superset \
  --cube-files ./cube_output \
  --url http://localhost:8088 \
  --username admin \
  --password admin \
  --cube-connection-name Cube

Configuration

Sample Configuration (sync-config.yaml)

connectors:
  superset:
    type: superset
    url: http://localhost:8088
    username: admin
    password: admin
    database_name: Cube
    
  tableau:
    type: tableau
    url: https://your-tableau-server.com
    username: your-username
    password: your-password
    
  powerbi:
    type: powerbi
    # PowerBI specific configuration

CLI Commands

dbt-to-cube

Generate Cube.js schema files from dbt models.

Options:

  • --manifest / -m: Path to dbt manifest.json file (required)
  • --catalog / -c: Path to dbt catalog.json file (optional if --sqlalchemy-uri is provided)
  • --sqlalchemy-uri / -s: SQLAlchemy database URI for fetching column types (optional if --catalog is provided)
    • Example: postgresql://user:password@localhost:5432/database
    • Example: mysql://user:password@localhost:3306/database
    • Example: snowflake://user:password@account/database/schema
  • --models: Comma-separated list of model names to process (optional, processes all if not specified)
    • Example: --models model1,model2,model3
  • --output / -o: Output directory for Cube.js files (required)
  • --template-dir / -t: Directory containing Cube.js templates (default: ./cube/templates)

Examples:

# Using catalog file
dbt-cube-sync dbt-to-cube -m manifest.json -c catalog.json -o output/

# Using database connection (no catalog needed)
dbt-cube-sync dbt-to-cube -m manifest.json -s postgresql://user:pass@localhost/db -o output/

# Filter specific models
dbt-cube-sync dbt-to-cube -m manifest.json -s postgresql://user:pass@localhost/db --models users,orders -o output/

cube-to-bi

Sync Cube.js schemas to BI tool datasets.

Arguments:

  • bi_tool: BI tool type (superset, tableau, powerbi)

Options:

  • --cube-files / -c: Directory containing Cube.js files (required)
  • --url / -u: BI tool URL (required)
  • --username / -n: BI tool username (required)
  • --password / -p: BI tool password (required)
  • --cube-connection-name / -d: Name of Cube database connection in BI tool (default: Cube)

Example:

dbt-cube-sync cube-to-bi superset -c cube_output/ -u http://localhost:8088 -n admin -p admin -d Cube

full-sync

Complete pipeline: dbt models โ†’ Cube.js schemas โ†’ BI tool datasets.

Options:

  • --dbt-manifest / -m: Path to dbt manifest.json file
  • --cube-dir / -c: Directory for Cube.js files
  • --template-dir / -t: Directory containing Cube.js templates
  • --bi-connector / -b: BI tool to sync to
  • --config-file / -f: Configuration file for BI tool connection

Architecture

dbt models (with metrics) 
    โ†“
dbt-cube-sync generate-cubes
    โ†“
Cube.js schemas
    โ†“
dbt-cube-sync sync-bi [connector]
    โ†“
BI Tool Datasets (Superset/Tableau/PowerBI)

Project Structure

dbt-cube-sync/
โ”œโ”€โ”€ dbt_cube_sync/
โ”‚   โ”œโ”€โ”€ cli.py                 # CLI interface
โ”‚   โ”œโ”€โ”€ config.py             # Configuration management
โ”‚   โ”œโ”€โ”€ core/
โ”‚   โ”‚   โ”œโ”€โ”€ dbt_parser.py     # dbt manifest parser
โ”‚   โ”‚   โ”œโ”€โ”€ db_inspector.py   # Database column type inspector (SQLAlchemy)
โ”‚   โ”‚   โ”œโ”€โ”€ cube_generator.py # Cube.js generator
โ”‚   โ”‚   โ””โ”€โ”€ models.py         # Pydantic data models
โ”‚   โ””โ”€โ”€ connectors/
โ”‚       โ”œโ”€โ”€ base.py           # Abstract base connector
โ”‚       โ”œโ”€โ”€ superset.py       # Superset implementation
โ”‚       โ”œโ”€โ”€ tableau.py        # Tableau placeholder
โ”‚       โ””โ”€โ”€ powerbi.py        # PowerBI placeholder
โ”œโ”€โ”€ Dockerfile                # Container definition
โ”œโ”€โ”€ pyproject.toml            # Poetry configuration
โ””โ”€โ”€ README.md

Adding New BI Connectors

  1. Create a new connector class inheriting from BaseConnector
  2. Implement the required abstract methods
  3. Register the connector using ConnectorRegistry.register()

Example:

from .base import BaseConnector, ConnectorRegistry

class MyBIConnector(BaseConnector):
    def _validate_config(self):
        # Validation logic
        pass
    
    def connect(self):
        # Connection logic
        pass
    
    def sync_cube_schemas(self, cube_dir):
        # Sync implementation
        pass

# Register the connector
ConnectorRegistry.register('mybi', MyBIConnector)

Docker Integration

The tool is designed to work in containerized environments with proper dependency orchestration:

  1. dbt docs: Runs dbt build then serves documentation
  2. dbt-cube-sync: Runs sync pipeline after dbt and Cube.js are ready
  3. BI Tools: Receive synced datasets after sync completes

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Implement your changes
  4. Add tests if applicable
  5. Submit a pull request

License

MIT License - see LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dbt_cube_sync-0.1.0a7.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dbt_cube_sync-0.1.0a7-py3-none-any.whl (23.5 kB view details)

Uploaded Python 3

File details

Details for the file dbt_cube_sync-0.1.0a7.tar.gz.

File metadata

  • Download URL: dbt_cube_sync-0.1.0a7.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.10.19 Linux/6.11.0-1018-azure

File hashes

Hashes for dbt_cube_sync-0.1.0a7.tar.gz
Algorithm Hash digest
SHA256 95e5705ad5c6c6bc3d950671caac1be1ba69e5dc224c617b89019259402bff71
MD5 b6f3b4a9725e331259ff992e09c0e2a6
BLAKE2b-256 9ecaa10a16cd43391b7e48cbb54b8c9267fb8a9b4ea99f5d832cf021fcf06040

See more details on using hashes here.

File details

Details for the file dbt_cube_sync-0.1.0a7-py3-none-any.whl.

File metadata

  • Download URL: dbt_cube_sync-0.1.0a7-py3-none-any.whl
  • Upload date:
  • Size: 23.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.10.19 Linux/6.11.0-1018-azure

File hashes

Hashes for dbt_cube_sync-0.1.0a7-py3-none-any.whl
Algorithm Hash digest
SHA256 a2fadc8ab2a2e22d0e9669f37c7767194229ad86736d070ef8d8c153ca227f70
MD5 b4830658a3adac9bb564c733a243195e
BLAKE2b-256 f38cd3d7f12885ee748c7a135f30234646b82fb146e9a56cdd50ce5211842ded

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page