Overview
Mage allows users to reference variables specific to your pipeline or project. These variables are accessible throughout your dbt profiles, and pipelines by using the following syntax.| Syntax | Description | Example |
|---|---|---|
{{ env_var('...') }} | Get from environment variables. | {{ env_var('ENV') }} |
{{ variables('...') }} | Get from runtime variables (used in YAML). | {{ variables('execution_date') }} |
{{ var('...') }} | Get from runtime variables (used in SQL). | {{ var('execution_date') }} |
Variable interpolation examples
dbt models
dbt profiles
dbt targets
Here, we’ve used a manually entered target to specify a postgres database dependent on the environment postgres_{{ env_var('ENV') }}.
| Environment | Key | Example string | Result |
|---|---|---|---|
prod | ENV | postgres_{{ env_var('ENV') }} | postgres_prod |
dev | ENV | postgres_{{ env_var('ENV') }} | postgres_dev |