Registry / data / dbt-extractor

dbt-extractor

JSON →
library0.6.0pypypi✓ verified 30d ago

dbt-extractor is a Python library that processes Jinja templates within dbt model files to analyze and extract metadata such as `ref`, `source`, and `config` calls. It is part of the `dbt-labs/dbt-parser-generator` repository. The tool, currently at version 0.6.0, prioritizes 100% certainty in its extraction, raising an exception if it cannot confidently extract values, rather than risking incorrect or incomplete output.

pip install dbt-extractor
INSTALL
IMPORT
SIG · DBT-EXTRACTOR
D
dbt-extractor
datapythonv0.6.0
Install
1.6s avg
Import
—
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.6.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.2MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 1.6s · import 0.000s · 19MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

extract_from_source
✓ from dbt_extractor import extract_from_source
✗ from dbt_extractor.main import extract_from_source

This quickstart demonstrates how to use `dbt-extractor` to parse a dbt model's SQL content and extract references to other models (`ref`), sources (`source`), and configurations (`config`). If the extraction is not 100% certain, an `ExtractionError` will be raised.

from dbt_extractor.main import extract_from_source from dbt_extractor.extractor import ExtractionError dbt_model_content = """ SELECT {{ ref('my_model') }} as model_data, {{ source('my_schema', 'my_table') }} as source_data, {{ config(materialized='table') }} FROM some_table """ try: extracted_data = extract_from_source(dbt_model_content) print("Extracted Refs:", extracted_data.refs) print("Extracted Sources:", extracted_data.sources) print("Extracted Configs:", extracted_data.configs) except ExtractionError as e: print(f"Extraction failed: {e}")
Debug
Known issues
gotchaInstallation of `dbt-extractor` requires a Rust toolchain (specifically `cargo`) to compile its underlying components. Users without Rust installed will encounter build errors during `pip install`.
fix
Install Rust and Cargo via `rustup.rs` or your system's package manager before installing `dbt-extractor`.
affects: All versions
gotchaThe library's core strategy is to be 100% certain about its extractions. If it encounters Jinja it cannot confidently parse and extract, it will raise an `ExtractionError` instead of returning potentially incomplete or incorrect results. This means some valid dbt Jinja might not be processed by `dbt-extractor` and may require alternative rendering.
fix
Be prepared to handle `ExtractionError` and consider fallback mechanisms (e.g., dbt's native Jinja rendering) for complex or unsupported Jinja patterns.
affects: All versions
gotcha`dbt-extractor` focuses on Jinja syntax extraction and does not perform validation of the underlying SQL syntax, schema existence, or data types. Errors in these areas will not be caught by `dbt-extractor` during compilation and will only manifest at runtime when dbt executes the SQL against your data warehouse.
fix
Supplement `dbt-extractor` usage with other tools like SQL linters (e.g., SQLFluff) and comprehensive dbt tests to ensure SQL correctness and data integrity.
affects: All versions
bugThere is an open bug where installation fails on free-threaded Python 3.14t, reporting an `ImportError: DLL load failed while importing dbt_extractor`.
fix
Avoid using free-threaded Python 3.14t or newer versions until this issue is resolved. Stick to officially supported Python versions (currently `>=3.9`).
affects: 0.6.0 (and potentially earlier) on Python 3.14t
Upgrade
Version history
0.6.0latest on PyPI · released Apr 7, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
20 hits · last 30 days
node
18
OpenAI (training)
1
Resources
dbt-extractor — pip install dbt-extractor · libregistry