Skip to main content

A lightweight SQL transformation tool for Databricks SQL

Project description

dbx-sql-runner

A lightweight, library-first SQL transformation tool for Databricks SQL, inspired by DBT.

Features

  • Simple SQL Models: Just write .sql files. No complex boilerplate.
  • Automated Dependency Management: Reference other models using {upstream_model} and let the runner build the DAG for you.
  • Environment Aware: Seamlessly switch between Dev and Prod using profiles.yml and Environment Variables.
  • Library Design: Import dbx_sql_runner in your Python scripts (great for Airflow/Databricks Jobs) or run it via CLI.

Installation

Development

To install the project in editable mode:

pip install -e .

Running Tests

To run the automated test suite:

pip install .[dev]
python -m pytest

Production

To install the package normally:

pip install dbx-sql-runner

Configuration (profiles.yml)

Create a profiles.yml file to store your credentials. Do not commit this file to version control.

server_hostname: "dbc-xxxxxxxx-xxxx.cloud.databricks.com"
http_path: "/sql/1.0/warehouses/xxxxxxxxxxxxxxxx"
access_token: "${DBX_ACCESS_TOKEN}"  # Use env vars for security!
catalog: "my_catalog"
schema: "my_schema"
sources:
    my_source: "prod_catalog.schema.table"

Usage

1. CLI (Easiest)

Run your project from the command line. By default, it looks for profiles.yml in the current directory.

# Initialize a new project
dbx-sql-runner init my_project

# Run with default profile (profiles.yml)
dbx-sql-runner run

# Run with custom profile
dbx-sql-runner run --profile my_config.yml

# Preview execution plan
dbx-sql-runner build

2. Python (Advanced)

For fine-grained control (e.g., inside a Databricks Job):

from dbx_sql_runner.api import run_project

# Run models in the 'models/' directory using the config from 'profiles.yml'
run_project(models_dir="models", config_path="profiles.yml")

Project Structure

.
├── models/                  # SQL files (.sql)
│   └── example.sql
├── dbx_sql_runner/          # Library source code
│   ├── adapters/            # Database Adapters
│   ├── project.py           # Model Loading & DAG
│   └── runner.py            # Execution Orchestrator
├── profiles.yml             # Configuration (gitignored)
├── pyproject.toml           # Project metadata
└── README.md

Defining Models

Create .sql files in your models/ directory.

  • Use header comments for metadata.
  • Use {upstream_model} syntax for references (automatically infers dependency).
-- name: my_table
-- materialized: table
-- partition_by: date, region

SELECT * FROM {source_view}
WHERE id > 100

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

dbx_sql_runner-0.2.0.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

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

dbx_sql_runner-0.2.0-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file dbx_sql_runner-0.2.0.tar.gz.

File metadata

  • Download URL: dbx_sql_runner-0.2.0.tar.gz
  • Upload date:
  • Size: 18.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dbx_sql_runner-0.2.0.tar.gz
Algorithm Hash digest
SHA256 9c352382a463cbe4a29b72c936f690d735de491ec010d3db43005a2dace99341
MD5 5094f31f8e59f41199da51ef3eb63ae5
BLAKE2b-256 2316ef8f2a8c96bb1c5b259269d9ae2e607dc14d015a3cb9d357e342b376a27c

See more details on using hashes here.

Provenance

The following attestation bundles were made for dbx_sql_runner-0.2.0.tar.gz:

Publisher: publish.yml on munish7771/dbx-sql-runner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dbx_sql_runner-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: dbx_sql_runner-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dbx_sql_runner-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eba52fb609e50cda2b30efcccb7b6cc702275f335e6d6b2ce8b174e09a3857b2
MD5 8e42a3229f133a40d487d5842bc95ad0
BLAKE2b-256 9e5360d26f80d1863b65ab60722c31a14a7d407a086afa45d73bed7e5f6c9d43

See more details on using hashes here.

Provenance

The following attestation bundles were made for dbx_sql_runner-0.2.0-py3-none-any.whl:

Publisher: publish.yml on munish7771/dbx-sql-runner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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