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 manifest.json

PyPI version python-cli

pip install dbterd==0.1.1 --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 command

# note that no relationship test = no erd relationship

# select all models in dbt_resto 
dbterd run -mp "./samples/v4-dbtresto" -o "./target"
# select only models in dbt_resto excluding staging
dbterd run -mp "./samples/v4-dbtresto" -o "./target" -s model.dbt_resto -ns model.dbt_resto.staging
# select only models in schema name "mart" excluding staging
dbterd run -mp "./samples/v4-dbtresto" -o "./target" -s schema:mart -ns model.dbt_resto.staging
# select only models in schema full name "dbt.dbo" excluding staging
dbterd run -mp "./samples/v4-dbtresto" -o "./target" -s schema:dbt.mart -ns model.dbt_resto.staging
# other samples
dbterd run -mp "./samples/v7-fivetranlog" -o "./target"
dbterd run -mp "./samples/v7-adfacebook" -o "./target"

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/manifest" -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

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

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

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.1.1.tar.gz (12.1 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.1.1-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dbterd-0.1.1.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.11.2 Linux/5.15.0-1033-azure

File hashes

Hashes for dbterd-0.1.1.tar.gz
Algorithm Hash digest
SHA256 981a93567a0d1d4cee1edc99df828b1d52be8e9431f86aea6a6915e23870236b
MD5 94a75701afaa030287251e88646d38f4
BLAKE2b-256 4ea79578d73dc191bc078fe40c6f835264345438767a6b88f268e5a110503a2a

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for dbterd-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8713706e4780d8d10f45ccf0f921aa044a11ea3e547e6987c3ea73234a0e03f2
MD5 83bc4c74be8321d88f2fb336e378583d
BLAKE2b-256 8469b196910d5a73bfdf0fd062590dba8cc2e12bac4234e5d53410ae1057a874

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