Generate the ERD-as-a-code from dbt artifacts
Project description
dbterd
Generate the ERD-as-a-code (DBML, Mermaid, PlantUML, GraphViz, D2, DrawDB) from dbt artifact files (dbt Core
) or from dbt metadata (dbt Cloud
)
Entity Relationships are configurably detected by (docs):
- Test Relationships (default)
- Semantic Entities (use
-a
option)
pip install dbterd --upgrade
Verify installation:
dbterd --version
[!TIP] For
dbt-core
Users, it's highly recommended to upgradedbt-artifacts-parser
to the latest version in order to support the newerdbt-core
version which would cause to have the new manifest / catalog json schema:
👉pip install dbt-artifacts-parser --upgrade
Quick examine with existing samples
-
Play with CLIs:
Click me
# select all models in dbt_resto dbterd run -ad samples/dbtresto # select all models in dbt_resto, Select multiple dbt resources dbterd run -ad samples/dbtresto -rt model -rt source # select only models in dbt_resto excluding staging dbterd run -ad samples/dbtresto -s model.dbt_resto -ns model.dbt_resto.staging # select only models in schema name mart excluding staging dbterd run -ad samples/dbtresto -s schema:mart -ns model.dbt_resto.staging # select only models in schema full name dbt.mart excluding staging dbterd run -ad samples/dbtresto -s schema:dbt.mart -ns model.dbt_resto.staging # other samples dbterd run -ad samples/fivetranlog dbterd run -ad samples/fivetranlog -rt model -rt source dbterd run -ad samples/facebookad dbterd run -ad samples/facebookad -rt model -rt source dbterd run -ad samples/shopify -s wildcard:*shopify.shopify__* dbterd run -ad samples/shopify -rt model -rt source dbterd run -ad samples/dbt-constraints -a "test_relationship:(name:foreign_key|c_from:fk_column_name|c_to:pk_column_name)" # your own sample without committing to repo dbterd run -ad samples/local -rt model -rt source
-
Play with Python API (whole ERD):
from dbterd.api import DbtErd erd = DbtErd().get_erd() print("erd (dbml):", erd) erd = DbtErd(target="mermaid").get_erd() print("erd (mermaid):", erd)
-
Play with Python API (1 model's ERD):
from dbterd.api import DbtErd 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)
Here is the 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
🏃Check out the Quick Demo with DBML!
Contributing ✨
If you've ever wanted to contribute to this tool, and a great cause, now is your chance!
See the contributing docs CONTRIBUTING for more information.
If you've found this tool to be very helpful, please consider giving the repository a star, sharing it on social media, or even writing a blog post about it 💌
Finally, super thanks to our Contributors:
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
File details
Details for the file dbterd-1.18.0.tar.gz
.
File metadata
- Download URL: dbterd-1.18.0.tar.gz
- Upload date:
- Size: 33.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.5 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ad38864c7fdf1147ed4014fb98c0988c8d51e87322d4a1fefb8327af9d297dc |
|
MD5 | 35dbba2e7cc774acafaf8015df7fd0a2 |
|
BLAKE2b-256 | a20cd1e2e3768c4d642761fef8cfdf0a700371c08546569b7c587cd247dacb81 |
File details
Details for the file dbterd-1.18.0-py3-none-any.whl
.
File metadata
- Download URL: dbterd-1.18.0-py3-none-any.whl
- Upload date:
- Size: 47.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.5 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 676371862f9edc45458c3bfcfe07ae1652c8bf99490d474a92d19dd153ddb9f7 |
|
MD5 | 9dc582bd47d042fafa53ba5649436102 |
|
BLAKE2b-256 | d913a313d5ff1fc9597a530b600cfd808a8eae0524071c6b7fb0a5caa6833353 |