CLI Reference (dbterd)¶
Run dbterd --help
or dbterd -h
to see the basic guideline for CLI Reference
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
dbterd run¶
Command to generate diagram-as-a-code file
Examples:
Usage: dbterd run [OPTIONS]
Run the convert
Options:
-ad, --artifacts-dir TEXT Specified the full path to dbt artifacts path
which known as /target directory [default:
C:\Users\DAT\Documents\Sources\dbterd\target]
-o, --output TEXT Output the result file. Default to the same
target dir [default:
C:\Users\DAT\Documents\Sources\dbterd\target]
-s, --select TEXT Selecttion criteria
-ns, --exclude TEXT Exclusion criteria
-t, --target TEXT Target to the diagram-as-code platform
[default: dbml]
-a, --algo TEXT Specified algorithm in the way to detect
diagram connectors [default:
test_relationship]
-mv, --manifest-version TEXT Specified dbt manifest.json version
-cv, --catalog-version TEXT Specified dbt catalog.json version
-rt, --resource-type TEXT Specified dbt resource type(seed, model,
source, snapshot),default:model, use examples,
-rt model -rt source
--omit-columns Flag to omit columns in diagram. Currently
only mermaid is supported
-h, --help Show this message and exit.
dbterd run --select (-s)¶
Selection criteria.
Select all dbt models if not specified, supports multiple options
Rules:
- By
name
: model name starts with input string - By
exact
: exact model name, formed asexact:model.package.name
- By
schema
: schema name starts with an input string, formed asschema:<your_schema_name>
- By
wildcard
: model name matches to a wildcard pattern, formed aswildcard:<your_wildcard>
- By
exposure
: exposure name, exact match
Examples:
AND
and OR
logic¶
AND
logic is applied to a single selection split by comma (,)OR
logic is applied to 2+ selection
Examples:
dbterd run --exclude (-ns)¶
Exclusion criteria. Rules are the same as Selection Criteria.
Do not exclude any dbt models if not specified, supports multiple options
Examples:
dbterd run --artifacts-dir (-ad)¶
Configure the path to directory containing dbt artifact files.
It will take the the nested /target
directory of --dbt-project-dir
if not specified.
Default to the current directory's
/target
if both this option and--dbt-project-dir
option are not specified
Examples:
dbterd run --output (-o)¶
Configure the path to directory containing the output diagram file.
Default to
./target
Examples:
dbterd run --output-file-name (-ofn)¶
Configure the output file name
Default to
output.{modulename}
which is defined in the target module
Examples:
dbterd run --target (-t)¶
Default to
dbml
Supported target, please visit Generate the Targets
Examples:
dbterd run --algo (-a)¶
Specified algorithm in the way to detect diagram connectors
Default to
test_relationship
In the advanced use case, the test name can be configurable by following syntax:
{algorithm_name}:(name:{contains_test_name}|c_from:{referencing_column_name}|c_to:{referenced_column_name})
In the above:
algorithm_name
:test_relationship
(only supported value now)contains_test_name
: Configure the test name (detected withcontains
logic). Default torelationship
c_from
: Configure the test metadata attribute (1) for the foreign key column name(s). If (1)'s value is multiple columns, it will concat them all with_and
wording > NOTE: It always looking at thecolumn_name
attribute firstlyc_to
: Configure the test metadata attribute (2) for the referenced column name(s). If (2)'s value is multiple columns, it will concat them all with_and
wording. Default tofield
For example, if you would use dbt-constraints
package
The dbt-constraints package is using different name of test which is close to the constraint names, in this case, you would need to customize the input string here:
Examples:
dbterd run --omit-columns¶
Flag to omit columns in diagram. Currently only mermaid is supported
Default to
False
Examples:
dbterd run --manifest-version (-mv)¶
Specified dbt manifest.json version
Auto detect if not specified
Examples:
dbterd run --catalog-version (-cv)¶
Specified dbt catalog.json version
Auto detect if not specified
Examples:
dbterd run --resource-type (-rt)¶
Specified dbt resource type(seed, model, source, snapshot).
Default to
["model"]
, supports multiple options
Examples:
dbterd run --dbt¶
Flag to indicate the Selection to follow dbt's one leveraging Programmatic Invocation
Default to
False
Examples:
dbterd run --dbt --dbt-auto-artifact¶
Flag to indicate force running dbt docs generate
to the targeted project in order to produce the dbt artifact files.
This option have to be enabled together with --dbt
option, and will override the value of --artifacts-dir
to be using the /target
dir of the value of --dbt-project-dir
.
Default to
False
Examples:
dbterd run --dbt-project-dir (-dpd)¶
Specified dbt project directory path
You should specified this option if your CWD is not the dbt project dir, and normally used with --dbt
enabled. It will take the value of --artifacts-dir
if not specified.
Default to the current directory if both this option and
--artifacts-dir
option are not specified
Examples:
dbterd run --dbt-target (-dt)¶
Specified dbt target name
Probably used with --dbt
enabled.
Default to the dbt's profile configuration
Examples:
dbterd run --entity-name-format (-enf)¶
Decide how the table name is generated on the ERD.
By default, the table name is the dbt node name (resource_type.package_name.model_name
).
Currently, it supports the following keys in the format:
resource.package.model
(by default)database.schema.table
- Or any other partial forms e.g.
schema.table
,resource.model
Examples:
dbterd run --omit-entity-name-quotes¶
Flag to omit the double quotes in the generated entity name. Currently only dbml
is supported.
Default to
False
Enabled it to allow dbdocs
to recognize the schemas and display them as grouping:
- With quotes:
- Without quotes:
⚠️ As of 2024 June: DBML doesn't support nested schema in the entity name which means 'database.schema.table' won't be allowed, but 'schema.table' does!
Examples:
dbterd run --dbt-cloud¶
Decide to download artifact files from dbt Cloud Job Run instead of compiling locally.
Check Download artifacts from a Job Run for more details.
Examples:
dbterd run-metadata¶
Command to generate diagram-as-a-code file by connecting to dbt Cloud Discovery API using GraphQL connection.
Check this guideline for more details.
Examples:
dbterd debug¶
Shows hidden configured values, which will help us to see what configs are passed into and how they are evaluated to be used.
Examples:
2023-09-08 16:43:45,066 - dbterd - INFO - Run with dbterd==1.0.0 (main.py:54)
2023-09-08 16:43:45,071 - dbterd - INFO - **Arguments used** (main.py:63)
2023-09-08 16:43:45,073 - dbterd - DEBUG - {
"artifacts_dir": "",
"output": "C:\\Users\\DAT\\Documents\\Sources\\dbterd\\target",
"select": [],
"exclude": [],
"target": "dbml",
"algo": "test_relationship",
"manifest_version": null,
"catalog_version": null,
"resource_type": [
"model"
],
"dbt": false,
"dbt_project_dir": "",
"dbt_target": null
} (main.py:64)
2023-09-08 16:43:45,079 - dbterd - INFO - **Arguments evaluated** (main.py:65)
2023-09-08 16:43:45,081 - dbterd - INFO - Using dbt artifact dir at: C:\Users\DAT\Documents\Sources\dbterd\target (base.py:41)
2023-09-08 16:43:45,082 - dbterd - INFO - Using dbt project dir at: C:\Users\DAT\Documents\Sources\dbterd (base.py:42)
2023-09-08 16:43:45,084 - dbterd - DEBUG - {
"artifacts_dir": "C:\\Users\\DAT\\Documents\\Sources\\dbterd\\target",
"output": "C:\\Users\\DAT\\Documents\\Sources\\dbterd\\target",
"select": [],
"exclude": [],
"target": "dbml",
"algo": "test_relationship",
"manifest_version": null,
"catalog_version": null,
"resource_type": [
"model"
],
"dbt": false,
"dbt_project_dir": "C:\\Users\\DAT\\Documents\\Sources\\dbterd",
"dbt_target": null
} (main.py:66)