Configuration Files¶
dbterd supports configuration files to streamline your workflow and reduce the need for repetitive CLI arguments. Think of it as your ERD generation control center – set it once, use it everywhere!
Supported Configuration Files¶
dbterd automatically discovers configuration files in your current directory:
.dbterd.yml- YAML configuration file (recommended for most users)pyproject.toml- TOML configuration with[tool.dbterd]section (great for Python projects)
Priority Order
If both files exist, dbterd checks them in this order:
pyproject.toml(if it contains[tool.dbterd]section).dbterd.yml
CLI arguments always override configuration file values.
Quick Start¶
Initialize Configuration¶
The easiest way to get started is using the dbterd init command:
This creates a .dbterd.yml file with all available options documented and ready to customize.
Available templates:
Overwrite existing config
Use --force to overwrite an existing configuration file:
Configuration File Examples¶
YAML Configuration (.dbterd.yml)¶
Here's a practical example for a dbt Core project:
# Output Settings
target: mermaid
output: ./docs/erd
output-file-name: schema.mmd
# Selection & Filtering
select:
- fct_*
- dim_*
exclude:
- stg_*
# Resource Types
resource-type:
- model
- source
# Relationship Detection
algo: test_relationship
# Entity Naming
entity-name-format: schema.table
omit-entity-name-quotes: false
omit-columns: false
# dbt Artifact Settings
artifacts-dir: ./target
bypass-validation: true
# dbt Project Settings (if using --dbt flag)
dbt: false
dbt-project-dir: .
dbt-auto-artifacts: false
TOML Configuration (pyproject.toml)¶
Add dbterd configuration to your existing pyproject.toml:
[tool.dbterd]
target = "mermaid"
output = "./docs/erd"
output-file-name = "schema.mmd"
select = [
"fct_*",
"dim_*"
]
exclude = ["stg_*"]
resource-type = ["model", "source"]
algo = "test_relationship"
entity-name-format = "schema.table"
omit-entity-name-quotes = false
omit-columns = false
artifacts-dir = "./target"
bypass-validation = true
dbt = false
dbt-project-dir = "."
dbt-auto-artifacts = false
dbt Cloud Configuration¶
For projects using dbt Cloud:
# Output Settings
target: dbml
output: ./target
# dbt Cloud Settings
dbt-cloud: true
dbt-cloud-host-url: cloud.getdbt.com
dbt-cloud-account-id: "12345"
dbt-cloud-job-id: "67890"
# Note: Store service-token in environment variable DBTERD_DBT_CLOUD_SERVICE_TOKEN
dbt-cloud-api-version: v2
# Selection
select:
- wildcard:*transaction*
# Resource Types
resource-type:
- model
[tool.dbterd]
target = "dbml"
output = "./target"
dbt-cloud = true
dbt-cloud-host-url = "cloud.getdbt.com"
dbt-cloud-account-id = "12345"
dbt-cloud-job-id = "67890"
# Note: Store service-token in environment variable DBTERD_DBT_CLOUD_SERVICE_TOKEN
dbt-cloud-api-version = "v2"
select = ["wildcard:*transaction*"]
resource-type = ["model"]
Security Best Practice
Never store sensitive values like service-token in configuration files. Use environment variables instead:
Available Configuration Options¶
All CLI parameters can be configured in files. Here's the complete reference:
Output Settings¶
| Option | Type | Default | Description |
|---|---|---|---|
target | string | dbml | Output format (dbml, mermaid, plantuml, graphviz, d2, drawdb) |
output | string | ./target | Output directory path |
output-file-name | string | - | Custom output file name |
Selection & Filtering¶
| Option | Type | Default | Description |
|---|---|---|---|
select | list | [] | Model/resource selection criteria |
exclude | list | [] | Model/resource exclusion criteria |
resource-type | list | ["model"] | Resource types to include (model, source) |
Relationship Detection¶
| Option | Type | Default | Description |
|---|---|---|---|
algo | string | test_relationship | Algorithm for detecting relationships |
Entity Naming¶
| Option | Type | Default | Description |
|---|---|---|---|
entity-name-format | string | resource.package.model | Format for entity names |
omit-entity-name-quotes | boolean | false | Remove quotes from entity names (dbml only) |
omit-columns | boolean | false | Hide columns in diagram (mermaid only) |
Artifact Settings¶
| Option | Type | Default | Description |
|---|---|---|---|
artifacts-dir | string | ./target | Path to dbt artifacts directory |
manifest-version | string | auto-detect | dbt manifest.json version |
catalog-version | string | auto-detect | dbt catalog.json version |
bypass-validation | boolean | true | Bypass Pydantic validation errors |
dbt Project Settings¶
| Option | Type | Default | Description |
|---|---|---|---|
dbt | boolean | false | Use dbt's selection syntax |
dbt-project-dir | string | . | Path to dbt project directory |
dbt-target | string | - | dbt target name |
dbt-auto-artifacts | boolean | false | Auto-generate artifacts via programmatic invocation |
dbt Cloud Settings¶
| Option | Type | Default | Description |
|---|---|---|---|
dbt-cloud | boolean | false | Enable dbt Cloud API integration |
dbt-cloud-host-url | string | cloud.getdbt.com | dbt Cloud host URL |
dbt-cloud-account-id | string | - | dbt Cloud account ID |
dbt-cloud-run-id | string | - | dbt Cloud run ID |
dbt-cloud-job-id | string | - | dbt Cloud job ID |
dbt-cloud-service-token | string | - | dbt Cloud service token (use env var!) |
dbt-cloud-api-version | string | v2 | dbt Cloud API version |
dbt-cloud-environment-id | string | - | Environment ID (for Discovery API) |
dbt-cloud-query-file-path | string | - | Custom GraphQL query file path (for Discovery API) |
Environment Variables
All options support environment variable overrides with the DBTERD_* prefix. For example:
Usage Patterns¶
Override Config with CLI Arguments¶
Configuration files provide defaults, but CLI arguments always take precedence:
Multiple Environments¶
Use different config files for different environments:
Custom config file paths
Currently, dbterd only auto-discovers config files in the current directory. Support for custom config file paths via --config flag is planned for a future release.
CI/CD Integration¶
Configuration files work great in CI/CD pipelines:
# GitHub Actions example
- name: Generate ERD
run: |
dbterd run
env:
DBTERD_DBT_CLOUD_SERVICE_TOKEN: ${{ secrets.DBT_CLOUD_TOKEN }}
The config file provides stable defaults while sensitive values come from secrets.
Auto-Detection Features¶
Artifact Version Detection¶
dbterd now automatically detects manifest and catalog versions from the metadata.dbt_schema_version field:
# No need to specify versions manually!
artifacts-dir: ./target
# manifest-version: 12 # Auto-detected
# catalog-version: 1 # Auto-detected
This means you rarely need to specify --manifest-version or --catalog-version anymore – dbterd figures it out for you!
Graceful Fallback¶
If no configuration file exists, dbterd falls back to CLI defaults gracefully. This means:
- Existing CLI workflows continue to work unchanged
- You can adopt config files incrementally
- No breaking changes to existing scripts
Key Naming Convention¶
Configuration files use kebab-case for keys (e.g., artifacts-dir, dbt-cloud), which automatically converts to the snake_case used internally by Python.
Both styles work in YAML/TOML:
Troubleshooting¶
Config File Not Found¶
If you create a config file but dbterd doesn't use it:
- Ensure the file is in your current working directory
- For
pyproject.toml, verify the[tool.dbterd]section exists - Check file permissions (must be readable)
Invalid YAML/TOML Syntax¶
If you see parsing errors:
- Validate your YAML syntax using a linter
- Ensure proper indentation (YAML is whitespace-sensitive)
- Check for missing colons or quotes
Config Not Taking Effect¶
If your config seems ignored:
- CLI arguments override config files – check your command
- Environment variables override config files – check
env | grep DBTERD - Use
dbterd debugto see evaluated configuration values
Python < 3.11 TOML Support¶
For Python versions below 3.11, install the tomli package:
Otherwise, you'll see:
Best Practices¶
- Use
.dbterd.ymlfor project defaults - Check it into version control so your team shares the same configuration - Store secrets in environment variables - Never commit tokens or credentials
- Override with CLI for one-off changes - No need to edit the config for quick experiments
- Document your configuration - Use YAML comments to explain why certain options are set
- Start with
dbterd init- Letdbterdgenerate a well-documented template for you
Learn More¶
- CLI Reference - Complete CLI documentation
- Choose the Parser - Understanding relationship detection algorithms
- dbt Cloud Integration - Using
dbterdwith dbt Cloud