<@U088WCP3B4P> how can i use different connection ...
# ask-elementary-ai
l
@kapa.ai how can i use different connection profiles for dev and prod?
k
A message from kapa.ai
To use different connection profiles for dev and prod with Elementary, you should define multiple targets under the same profile (usually named elementary) in your
profiles.yml
file. For example:
Copy code
yaml elementary:   target: dev   outputs:     dev:       type: snowflake       account: <dev_account>       user: <dev_user>       password: <dev_password>       role: <dev_role>       warehouse: <dev_warehouse>       database: <dev_db>       schema: <dev_schema>       threads: 8     prod:       type: snowflake       account: <prod_account>       user: <prod_user>       password: <prod_password>       role: <prod_role>       warehouse: <prod_warehouse>       database: <prod_db>       schema: <prod_schema>       threads: 8
You can then specify which target to use when running Elementary CLI commands by using the
--profile-target
(or
-t
) flag. For example, to use the prod connection:
Copy code
edr report --profile-target prod
The
--env
flag is only cosmetic—it sets the environment name in the report and alerts, but does not control which connection is used. Always use
--profile-target
(or
-t
) to select the correct connection for dev or prod environments. If you omit the flag, the default target specified in your profile will be used [see example](https://slack.com/archives/C02CTC89LAX/p1699363455840319), [another example](https://slack.com/archives/C02CTC89LAX/p1700490053029329), [setup guidance](https://slack.com/archives/C02CTC89LAX/p1678354399287839). If you want to use different profile names (not just targets), you must ensure the profile is named
elementary
in your
profiles.yml
, as the CLI expects this by default. If you need to use a different profile name, you can use the
--profiles-dir
flag to point to a different
profiles.yml
file, but the profile section should still be named
elementary
 [see discussion](https://slack.com/archives/C02CTC89LAX/p1696334751498889). Summary: - Define multiple targets (e.g., dev, prod) under the
elementary
profile in
profiles.yml
. - Use
--profile-target dev
or
--profile-target prod
with your
edr
commands to select the environment. - The
--env
flag is only for display in reports/alerts, not for connection selection.
l
@kapa.ai and how can I deactivate by default (but still quickly activate during development) elementary on dev?
k
A message from kapa.ai
To deactivate Elementary by default in your dev environment—but still allow for quick activation during development—you can use a variable in your
dbt_project.yml
to control whether Elementary models are enabled. Here’s a recommended approach: 1. Set a variable with a default value of
false
(deactivated) for dev:
Copy code
yaml vars:   enable_elementary: false  models:   elementary:     +schema: "elementary"     +enabled: "{{ var('enable_elementary', false) }}"
2. Activate Elementary when needed by passing the variable as
true
in your dbt CLI command:
Copy code
sh dbt run --vars '{"enable_elementary": true}'
This way, Elementary is disabled by default in dev, but you or any developer can quickly enable it for a specific run by setting the variable to
true
on the command line. This pattern is recommended by the Elementary team and community for flexible environment control [see example and discussion](https://slack.com/archives/C02CTC89LAX/p1669625539486519). You can also make the default depend on the environment, for example:
Copy code
yaml +enabled: "{{ var('enable_elementary', target.name in ['prod', 'acc']) }}"
This enables Elementary only for specific targets by default, but still allows override via the CLI var [see example](https://slack.com/archives/C02CTC89LAX/p1669625539486519). Summary: - Use a variable to control enablement. - Default to
false
in dev. - Override with
--vars
when you want to activate Elementary for development.