# Environment variable substitution is not working for me when connecting GE to my database

**URL:** https://discourse.greatexpectations.io/t/environment-variable-substitution-is-not-working-for-me-when-connecting-ge-to-my-database/72
**Category:** Archive
**Created:** [March 9, 2020, 9:49pm UTC](https://discourse.greatexpectations.io/t/environment-variable-substitution-is-not-working-for-me-when-connecting-ge-to-my-database/72 "2020-03-09T21:49:14Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![eugene.mandel](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.greatexpectations.io/eugene.mandel/32/22_2.png) [@eugene.mandel](https://discourse.greatexpectations.io/u/eugene.mandel)
#### Post date: [March 9, 2020, 9:49pm UTC](https://discourse.greatexpectations.io/t/environment-variable-substitution-is-not-working-for-me-when-connecting-ge-to-my-database/72/1 "2020-03-09T21:49:14Z")

</div>

A user asked this question on Slack - reposting it here, since others might run into this issue as well.

The user wanted to provide the database username and password to GE using env variables (following this doc: [https://docs.greatexpectations.io/en/latest/reference/data\_context\_reference.html#managing-environment-and-secrets](https://docs.greatexpectations.io/en/latest/reference/data_context_reference.html#managing-environment-and-secrets))

The user used the ${…} syntax in the uncommitted/config\_variables.yml, but GE would not connect to the database and it was clear that the env vars are not being substituted:

![image (1)](https://canada1.discourse-cdn.com/flex031/uploads/greatexpectations/original/1X/260181188c9a8d316d8daf449b63c45c4681a933.png)

Here is why this did not work:

Data Context configuration supports the substitution syntax only in the great\_expectations.yml config file, so any ${…} in config\_variables.yml is not going to be substituted.

If you want to pass the database password to a datasource via an env var, modify this datasource’s config block in great\_expectations.yml:

Before:

```
datasources:
    datawarehouse:
        class_name: SqlAlchemyDatasource
        data_asset_type:
            class_name: SqlAlchemyDataset
        module_name:
        credentials: ${datawarehouse}

```

After:

```
datasources:
    datawarehouse:
        class_name: SqlAlchemyDatasource
        data_asset_type:
            class_name: SqlAlchemyDataset
        module_name:
        credentials:
            drivername: postgresql+psycopg2
            host: myhost.foo
            port: '5439'
            database: mydatabase
            username: ${DATAWAREHOUSE_USERNAME}
            password: ${DATAWAREHOUSE_PASSWORD}

```

(DATAWAREHOUSE\_USERNAME and DATAWAREHOUSE\_PASSWORD are env variables)

---

<div class="post-metadata">

### Author: ![tom.mitic](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.greatexpectations.io/tom.mitic/32/93_2.png) [@tom.mitic](https://discourse.greatexpectations.io/u/tom.mitic)
#### Post date: [October 29, 2020, 5:19pm UTC](https://discourse.greatexpectations.io/t/environment-variable-substitution-is-not-working-for-me-when-connecting-ge-to-my-database/72/2 "2020-10-29T17:19:31Z")

</div>

What version of GE is this in… with v0.12.6 of the framework all env vars are being substitued in the GE file from env vars sans the password field

I don’t want to hard code the password into this file since it breaks my company’s security standards

---

<div class="post-metadata">

### Author: ![anthony](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.greatexpectations.io/anthony/32/68_2.png) [@anthony](https://discourse.greatexpectations.io/u/anthony)
#### Post date: [October 29, 2020, 5:23pm UTC](https://discourse.greatexpectations.io/t/environment-variable-substitution-is-not-working-for-me-when-connecting-ge-to-my-database/72/3 "2020-10-29T17:23:29Z")

</div>

Hi @tom.mitic! Today we are in the process of releasing GE v0.12.7 which fixes this issue and also allows for multiple substitutions per line. It should be released today! Apologies for the inconvenience and the original change, it was inadvertent - we were trying to fix a different bug.

---

<div class="post-metadata">

### Author: ![tom.mitic](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.greatexpectations.io/tom.mitic/32/93_2.png) [@tom.mitic](https://discourse.greatexpectations.io/u/tom.mitic)
#### Post date: [October 29, 2020, 5:48pm UTC](https://discourse.greatexpectations.io/t/environment-variable-substitution-is-not-working-for-me-when-connecting-ge-to-my-database/72/4 "2020-10-29T17:48:13Z")

</div>

Ok thanks for the update

---

<div class="post-metadata">

### Author: ![anthony](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.greatexpectations.io/anthony/32/68_2.png) [@anthony](https://discourse.greatexpectations.io/u/anthony)
#### Post date: [October 29, 2020, 6:47pm UTC](https://discourse.greatexpectations.io/t/environment-variable-substitution-is-not-working-for-me-when-connecting-ge-to-my-database/72/5 "2020-10-29T18:47:30Z")

</div>

FYI we just released v0.12.7 - please let us know if this does not solve your issue!

---

<div class="post-metadata">

### Author: ![tom.mitic](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.greatexpectations.io/tom.mitic/32/93_2.png) [@tom.mitic](https://discourse.greatexpectations.io/u/tom.mitic)
#### Post date: [October 29, 2020, 6:52pm UTC](https://discourse.greatexpectations.io/t/environment-variable-substitution-is-not-working-for-me-when-connecting-ge-to-my-database/72/6 "2020-10-29T18:52:37Z")

</div>

It worked for us. And has unblocked our workflow.
