Generate the ERD-as-a-code from dbt artifacts
Project description
dbterd
Generate ERD-as-a-code from your dbt projects
Transform your dbt artifact files or metadata into stunning Entity Relationship Diagrams using multiple formats: DBML, Mermaid, PlantUML, GraphViz, D2, and DrawDB
🎯 Entity Relationship Detection
dbterd intelligently detects entity relationships through:
- 🧪 Test Relationships (default method)
- 🏛️ Semantic Entities (use
-aoption)
For detailed configuration options, see our CLI References.
🎨 Supported Output Formats
| Format | Description | Use Case |
|---|---|---|
| DBML | Database Markup Language | Interactive web diagrams |
| Mermaid | Markdown-friendly diagrams | Documentation, GitHub |
| PlantUML | Text-based UML | Technical documentation |
| GraphViz | DOT graph description | Complex relationship visualization |
| D2 | Modern diagram scripting | Beautiful, customizable diagrams |
| DrawDB | Web-based database designer | Interactive database design |
🎯 Try the Quick Demo with DBML format!
🚀 Installation
pip install dbterd --upgrade
Verify Installation:
dbterd --version
[!TIP] For dbt-core users: It's highly recommended to keep
dbt-artifacts-parserupdated to the latest version to support newerdbt-coreversions and their manifest/catalog json schemas:pip install dbt-artifacts-parser --upgradeNote:
dbterdnow automatically bypasses Pydantic validation errors by default, which helps with compatibility when using newer dbt artifact schemas.
⚙️ Configuration Files
Tired of typing the same CLI arguments repeatedly? dbterd supports configuration files to streamline your workflow!
# Initialize a configuration file
dbterd init
# Now just run with your saved settings
dbterd run
Supported formats:
.dbterd.yml- YAML configuration (recommended)pyproject.toml- Add[tool.dbterd]section to your existing Python project config
Learn more in the Configuration Files Guide.
💡 Examples
CLI Examples
🖱️ Click to explore CLI examples
# 📊 Select all models in dbt_resto
dbterd run -ad samples/dbtresto
# 🎯 Select multiple dbt resources (models + sources)
dbterd run -ad samples/dbtresto -rt model -rt source
# 🔍 Select models excluding staging
dbterd run -ad samples/dbtresto -s model.dbt_resto -ns model.dbt_resto.staging
# 📋 Select by schema name
dbterd run -ad samples/dbtresto -s schema:mart -ns model.dbt_resto.staging
# 🏷️ Select by full schema name
dbterd run -ad samples/dbtresto -s schema:dbt.mart -ns model.dbt_resto.staging
# 🌟 Other sample projects
dbterd run -ad samples/fivetranlog -rt model -rt source
dbterd run -ad samples/facebookad -rt model -rt source
dbterd run -ad samples/shopify -s wildcard:*shopify.shopify__*
# 🔗 Custom relationship detection
dbterd run -ad samples/dbt-constraints -a "test_relationship:(name:foreign_key|c_from:fk_column_name|c_to:pk_column_name)"
# 💻 Your local project
dbterd run -ad samples/local -rt model -rt source
Python API Examples
Generate Complete ERD
from dbterd.api import DbtErd
# Generate DBML format
erd = DbtErd().get_erd()
print("ERD (DBML):", erd)
# Generate Mermaid format
erd = DbtErd(target="mermaid").get_erd()
print("ERD (Mermaid):", erd)
Generate Single Model ERD
from dbterd.api import DbtErd
# Get ERD for specific model
dim_prize_erd = DbtErd(target="mermaid").get_model_erd(
node_unique_id="model.dbt_resto.dim_prize"
)
print("ERD of dim_prize (Mermaid):", dim_prize_erd)
Sample Output:
erDiagram
"MODEL.DBT_RESTO.DIM_PRIZE" {
varchar prize_key
nvarchar prize_name
int prize_order
}
"MODEL.DBT_RESTO.FACT_RESULT" {
varchar fact_result_key
varchar box_key
varchar prize_key
date date_key
int no_of_won
float prize_value
float prize_paid
int is_prize_taken
}
"MODEL.DBT_RESTO.FACT_RESULT" }|--|| "MODEL.DBT_RESTO.DIM_PRIZE": prize_key
🤝 Contributing
We welcome contributions! 🎉
Ways to contribute: 🐛 Report bugs | 💡 Suggest features | 📝 Improve documentation | 🔧 Submit pull requests
See our Contributing Guide for detailed information.
Show your support:
- ⭐ Star this repository
- 📢 Share on social media
- ✍️ Write a blog post
- ☕ Buy me a coffee
👥 Contributors
A huge thanks to our amazing contributors! 🙏
📧 Support
Need help? We're here for you! Check 📖 Documentation, 🐛 Report Issues and 💬 Discussions
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 dbterd-1.23.0.tar.gz.
File metadata
- Download URL: dbterd-1.23.0.tar.gz
- Upload date:
- Size: 52.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e883d67c4a40f9ebb5aa368c2547fd381e5cd7447e47d5e418f64d2027831d2
|
|
| MD5 |
1e77043d95759284c4bd35dd732a0b6a
|
|
| BLAKE2b-256 |
c9741242963e4c04a01487668d8e0516fe1a2f20b341f08b258c7cd206818efa
|
Provenance
The following attestation bundles were made for dbterd-1.23.0.tar.gz:
Publisher:
pypi-publish.yml on datnguye/dbterd
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dbterd-1.23.0.tar.gz -
Subject digest:
5e883d67c4a40f9ebb5aa368c2547fd381e5cd7447e47d5e418f64d2027831d2 - Sigstore transparency entry: 763687725
- Sigstore integration time:
-
Permalink:
datnguye/dbterd@0505424311726b24e64bd153beaefa8fb37b99ca -
Branch / Tag:
refs/tags/1.23.0 - Owner: https://github.com/datnguye
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@0505424311726b24e64bd153beaefa8fb37b99ca -
Trigger Event:
push
-
Statement type:
File details
Details for the file dbterd-1.23.0-py3-none-any.whl.
File metadata
- Download URL: dbterd-1.23.0-py3-none-any.whl
- Upload date:
- Size: 69.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 |
e8bf42626e59066801559d309db808af2db745751407a64bbb4aa95df14af42b
|
|
| MD5 |
53731a7c5f7d187736a595373a3b26d1
|
|
| BLAKE2b-256 |
1a81791c00d190c863534edec69a5712140b12628f962c906561d283297013f9
|
Provenance
The following attestation bundles were made for dbterd-1.23.0-py3-none-any.whl:
Publisher:
pypi-publish.yml on datnguye/dbterd
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dbterd-1.23.0-py3-none-any.whl -
Subject digest:
e8bf42626e59066801559d309db808af2db745751407a64bbb4aa95df14af42b - Sigstore transparency entry: 763687727
- Sigstore integration time:
-
Permalink:
datnguye/dbterd@0505424311726b24e64bd153beaefa8fb37b99ca -
Branch / Tag:
refs/tags/1.23.0 - Owner: https://github.com/datnguye
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@0505424311726b24e64bd153beaefa8fb37b99ca -
Trigger Event:
push
-
Statement type: