dbterd is a Command Line Interface (CLI) to convert dbt manifest.json file to diagram file
Project description
dbterd
CLI to generate Diagram-as-a-code file (DBML, Mermaid) from dbt artifact files (required: manifest.json, catalog.json)
Version 0.1: only required
manifest.json
pip install dbterd --upgrade
Verify installed version:
dbterd --version
dbterd -h
Usage: dbterd [OPTIONS] COMMAND [ARGS]...
Tools for producing diagram-as-code
Options:
--version Show the version and exit.
-h, --help Show this message and exit.
Commands:
debug Inspect the hidden magics
run Run the convert
Specify one of these sub-commands and you can find more help from there.
Quick examine with existing samples
# select all models in dbt_resto
dbterd run -ad "samples/dbtresto" -o "target"
# select all models in dbt_resto, Select multiple dbt resources
dbterd run -ad "samples/dbtresto" -o "target" -rt "model" -rt "source"
# select only models in dbt_resto excluding staging
dbterd run -ad "samples/dbtresto" -o "target" -s model.dbt_resto -ns model.dbt_resto.staging
# select only models in schema name "mart" excluding staging
dbterd run -ad "samples/dbtresto" -o "target" -s schema:mart -ns model.dbt_resto.staging
# select only models in schema full name "dbt.mart" excluding staging
dbterd run -ad "samples/dbtresto" -o "target" -s schema:dbt.mart -ns model.dbt_resto.staging
# other samples
dbterd run -ad "samples/fivetranlog" -o "target"
dbterd run -ad "samples/fivetranlog" -o "target" -rt "model" -rt "source"
dbterd run -ad "samples/facebookad" -o "target"
dbterd run -ad "samples/facebookad" -o "target" -rt "model" -rt "source"
dbterd run -ad "samples/shopify" -o "target"
dbterd run -ad "samples/shopify" -o "target" -rt "model" -rt "source"
# your own sample without commiting to repo
dbterd run -mp "samples/local" -o "target" -rt "model" -rt "source"
Decide to exclude Relationship Tests from ERD generated
Add ignore_in_erd attribute into your test's meta:
version: 2
models:
- name: your_model
columns:
- name: your_column
tests:
- relationships_test:
to: ref('your_other_model')
field: your_other_column
meta:
ignore_in_erd: 1
Quick DEMO
1. Produce your manifest json
In your dbt project (I am using dbt-resto/integration_tests for demo purpose), try to build the docs:
dbt docs generate
2. Generate DBML
Copy manifest.json into a specific folder, and run
dbterd run -mp "/path/to/dbt/target" -o "/path/to/output"
# dbterd run -mp "./target/v4-dbtresto" -o "./target" -s model.dbt_resto -ns model.dbt_resto.staging
File ./target/output.dbml will be generated as the result
3. Build database docs site (Optional)
Assuming you're already familiar with dbdocs
dbdocs build "/path/to/output/output.dbml"
# dbdocs build "./target/output.dbml"
Your terminal should provide the info as below:
√ Parsing file content
? Project name: poc
‼ Password is not set for 'poc'
√ Done. Visit: https://dbdocs.io/datnguye/poc
The site will be looks like:
Result after applied Model Selection:
Contributing ✨
If you've ever wanted to contribute to this tool, and a great cause, now is your chance!
See the contributing docs CONTRIBUTING.md for more information
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.1.0b1.tar.gz.
File metadata
- Download URL: dbterd-1.1.0b1.tar.gz
- Upload date:
- Size: 14.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.11.3 Linux/5.15.0-1035-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ca172eee4090f9d995ace2e6ddcc2a9392083d8a4d8f830380384e21866ed0d
|
|
| MD5 |
f4135638ea822a25b6488c5d75a22689
|
|
| BLAKE2b-256 |
3b62c0d6576a49756099d16e80a93515e3b52d677393d498592f584ce81bb1c1
|
File details
Details for the file dbterd-1.1.0b1-py3-none-any.whl.
File metadata
- Download URL: dbterd-1.1.0b1-py3-none-any.whl
- Upload date:
- Size: 20.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.11.3 Linux/5.15.0-1035-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1cffb642df8090ed6b4b24cbe630bdf6bddddb03e7385ce00463c76c59c6b65d
|
|
| MD5 |
386dc4fc392dcf6a52c8b5f3b56456ed
|
|
| BLAKE2b-256 |
d0fe630d66cdcdf36858dbc2350a33ddc96a1a1da58fd6717246f70c181feb43
|