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
- Example:
--models: Comma-separated list of model names to process (optional, processes all if not specified)- Example:
--models model1,model2,model3
- Example:
--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
- Create a new connector class inheriting from
BaseConnector - Implement the required abstract methods
- 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:
- dbt docs: Runs
dbt buildthen serves documentation - dbt-cube-sync: Runs sync pipeline after dbt and Cube.js are ready
- BI Tools: Receive synced datasets after sync completes
Contributing
- Fork the repository
- Create a feature branch
- Implement your changes
- Add tests if applicable
- Submit a pull request
License
MIT License - see LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dbt_cube_sync-0.1.0a6.tar.gz.
File metadata
- Download URL: dbt_cube_sync-0.1.0a6.tar.gz
- Upload date:
- Size: 19.2 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b13995e4deab6b33d80a0a6d8622724a96270a1a3ad692e9e2f197dc42c8409
|
|
| MD5 |
98a6227c383f1c5ea86416b5690adbc4
|
|
| BLAKE2b-256 |
b0b1fc154d704c7ec9358975aa4010e64f0b98cdb431513a9c1797da59ff3928
|
File details
Details for the file dbt_cube_sync-0.1.0a6-py3-none-any.whl.
File metadata
- Download URL: dbt_cube_sync-0.1.0a6-py3-none-any.whl
- Upload date:
- Size: 23.0 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5690b02da4d3302e7ccb746ee323a8f5eca30e445a7cf8aa468f2183ba964196
|
|
| MD5 |
f45090fe5d561c1b34c3325d2a335e33
|
|
| BLAKE2b-256 |
5f30e3e7a8bd82366b9a6bf11ee4267dc336512282b2b9515801ee9a6c84f422
|