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):
-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
Play with CLIs:
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!
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: