Skip to main content

dbterd is a Command Line Interface (CLI) to convert dbt manifest.json file to diagram file

Project description

dbterd

CLI to generate DBML file from dbt artifact files (required: manifest.json, catalog.json)

Version 0.1: only required manifest.json

PyPI version python-cli License: MIT python codecov

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 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/facebookad" -o "target"
dbterd run -ad "samples/shopify" -o "target"

# your own sample without commiting to repo
dbterd run -mp "samples/local" -o "target"

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:

screencapture-dbdocs-io-datnguye-poc-2022-12-18-22_02_28.png

Result after applied Model Selection: screencapture-dbdocs-io-datnguye-poc-2023-02-25-10_29_32.png

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

dbterd-0.2.1.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dbterd-0.2.1-py3-none-any.whl (19.7 kB view details)

Uploaded Python 3

File details

Details for the file dbterd-0.2.1.tar.gz.

File metadata

  • Download URL: dbterd-0.2.1.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.11.2 Linux/5.15.0-1034-azure

File hashes

Hashes for dbterd-0.2.1.tar.gz
Algorithm Hash digest
SHA256 56b98c559e52b19717af0141ed2b34b558b6fb4883cb1b766ab35c42b1b4a620
MD5 97edfaccc0401f925143d61337b2a89a
BLAKE2b-256 daeab21c79deb4bbee1d20797039241e8e713f3e7b7cc0f3452f3d5d04a051b5

See more details on using hashes here.

File details

Details for the file dbterd-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: dbterd-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 19.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.11.2 Linux/5.15.0-1034-azure

File hashes

Hashes for dbterd-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 98b148f0f509e6679a24d2305058314c28dbe76f09136125f26b160987ee9dfe
MD5 3f8899b6247d3820f93eee654a4844ee
BLAKE2b-256 f4dbc78eb60d8c5bcab1781e0af9ec0ff0ba7361ce3fe956db2a39d9f5f1a3f5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page