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.
📘 Full Documentation: https://munish7771.github.io/dbx-sql-runner/
Features
- Simple SQL Models: Just write
.sqlfiles. 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.ymland Environment Variables. - Library Design: Import
dbx_sql_runnerin your Python scripts (great for Airflow/Databricks Jobs) or run it via CLI. - Flexible Sources: Define external tables in
profiles.ymland reference them as{source_name}in your SQL. - Automated Linting: Built-in linter (using Ruff) to ensure code quality.
- Alerting: Send notifications to a webhook URL on run completion or failure.
Installation
Development
To install the project in editable mode:
pip install -e .
To run docs site:
npm run start
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}" # Env var expansion supported for any field
catalog: "my_catalog"
schema: "my_schema"
sources:
# keys here can be used in SQL as {my_source}
my_source: "prod_catalog.schema.table"
raw_sales: "raw_data.sales_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
│ ├── api.py # Public API
│ ├── cli.py # Command Line Interface
│ ├── exceptions.py # Custom Exceptions
│ ├── linter.py # Linting Logic
│ ├── models.py # Data Models
│ ├── project.py # Model Loading & DAG
│ ├── runner.py # Execution Orchestrator
│ └── scaffold.py # Project Scaffolding
├── 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). - Use
{source_name}to reference sources defined inprofiles.yml.
-- name: my_first_model
-- materialized: table
-- partition_by: date
/*
Welcome to your first dbx-sql-runner model!
This is where you define your SQL logic.
You can refer to other models like this: {upstream_model_name}
Or refer to sources defined in profiles.yml like this: {my_source}
*/
SELECT
1 as id,
current_date() as date,
'Hello World' as message
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
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 dbx_sql_runner-0.2.2.tar.gz.
File metadata
- Download URL: dbx_sql_runner-0.2.2.tar.gz
- Upload date:
- Size: 21.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27836817340d764e30a6767dc0ccd97604f683eba2438ade5805cf12b62ce254
|
|
| MD5 |
c7df9b1d49998e9446369506b0a5dfe0
|
|
| BLAKE2b-256 |
b47a4ff8ab10df8ccf6e7acb78b66496f83c22d35f338a1d991b3f9fef721f63
|
Provenance
The following attestation bundles were made for dbx_sql_runner-0.2.2.tar.gz:
Publisher:
publish.yml on munish7771/dbx-sql-runner
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dbx_sql_runner-0.2.2.tar.gz -
Subject digest:
27836817340d764e30a6767dc0ccd97604f683eba2438ade5805cf12b62ce254 - Sigstore transparency entry: 853968924
- Sigstore integration time:
-
Permalink:
munish7771/dbx-sql-runner@ef77f095db272253bdde67876916f7abee70671e -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/munish7771
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ef77f095db272253bdde67876916f7abee70671e -
Trigger Event:
release
-
Statement type:
File details
Details for the file dbx_sql_runner-0.2.2-py3-none-any.whl.
File metadata
- Download URL: dbx_sql_runner-0.2.2-py3-none-any.whl
- Upload date:
- Size: 17.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b0a6f1b71119c1b9bd3b8b40a98c8bc2f525d21191b5dc6772621bd3a18f423
|
|
| MD5 |
5c3160abd607a04548caa5600490875c
|
|
| BLAKE2b-256 |
a52f4ff7c2cade248e5bfb753ae3b9b9f2d59905e97fa4fcbafa98b6d0eb7512
|
Provenance
The following attestation bundles were made for dbx_sql_runner-0.2.2-py3-none-any.whl:
Publisher:
publish.yml on munish7771/dbx-sql-runner
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dbx_sql_runner-0.2.2-py3-none-any.whl -
Subject digest:
7b0a6f1b71119c1b9bd3b8b40a98c8bc2f525d21191b5dc6772621bd3a18f423 - Sigstore transparency entry: 853968937
- Sigstore integration time:
-
Permalink:
munish7771/dbx-sql-runner@ef77f095db272253bdde67876916f7abee70671e -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/munish7771
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ef77f095db272253bdde67876916f7abee70671e -
Trigger Event:
release
-
Statement type: