[FEAT] Expose Python APIs officially
datnguye opened this issue Β· comments
Describe the solution you'd like
Expose Python APIs officially
-
API to get a 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)
-
API to get model's ERD: this model +1 level connected nodes
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_date (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
API docs will be generated by pdoc
π beta site
PS: Mainly to support dbt docs generate
's result with the ERD enrichment
Give me a π if you think it should be available asap! Thanks
Great idea! In fact, I'm writing a script to wrap dbterd for the same purpose in my work case, so I thought it would help many people like me.
However, I think that there are many cases (including my case) where I would like to customize the output to markdown, so I hope that the dbterd run
currently provided will be maintained as it is.
Great idea! In fact, I'm writing a script to wrap dbterd for the same purpose in my work case, so I thought it would help many people like me.
However, I think that there are many cases (including my case) where I would like to customize the output to markdown, so I hope that the
dbterd run
currently provided will be maintained as it is.
Good point for the various of customizations. Maybe this would just support the Python API for that purpose only.
https://dbterd.datnguyen.de/1.12-beta/api-docs/dbterd/api.html
Python API docs site preview π