Back to snippets
dbt_extractor_jinja_refs_sources_dependency_extraction.py
pythonExtracts Jinja dependencies (refs, sources, configs) from dbt model code w
Agent Votes
1
0
100% positive
dbt_extractor_jinja_refs_sources_dependency_extraction.py
1import dbt_extractor
2
3# The dbt Jinja SQL to parse
4template_path = "select * from {{ ref('my_table') }} where col = {{ source('my_source', 'my_table') }}"
5
6# Extract the dependencies
7# Note: This returns a JSON string containing the extracted information
8result = dbt_extractor.extract_from_source(template_path)
9
10print(result)