# how to assign value of environmental variable to variable in project yml file

**URL:** <https://discourse.getdbt.com/t/how-to-assign-value-of-environmental-variable-to-variable-in-project-yml-file/7814>\
**Category:** Help\
**Created:** [April 13, 2023, 8:09am UTC](https://discourse.getdbt.com/t/how-to-assign-value-of-environmental-variable-to-variable-in-project-yml-file/7814 "2023-04-13T08:09:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rjames](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/rjames/32/1656_2.png) [@rjames](https://discourse.getdbt.com/u/rjames)\
**Post date:** [April 13, 2023, 8:09am UTC](https://discourse.getdbt.com/t/how-to-assign-value-of-environmental-variable-to-variable-in-project-yml-file/7814/1 "2023-04-13T08:09:58Z")

</div>

Hi,  
how to assign value of environmental variable to variable in project yml file

eg.  
vars:  
database\_source: “{{ env\_var(‘DBT\_DATA\_LAKE\_DB’) }}”

This doesn’t work. When I assign the value to model source it just returns the string value and not the value of the environment variable.

sources:

- name: schemaname  
database: “{{var(‘database\_source’)}}”

the query is generated as {{ env\_var(‘DBT\_DATA\_LAKE\_DB’) }}.schemaname.tablename

---

<div class="post-metadata">

**Author:** ![Surya](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/surya/32/3763_2.png) [@Surya](https://discourse.getdbt.com/u/Surya)\
**Post date:** [April 17, 2023, 3:30am UTC](https://discourse.getdbt.com/t/how-to-assign-value-of-environmental-variable-to-variable-in-project-yml-file/7814/2 "2023-04-17T03:30:09Z")

</div>

i also tried the same, the variable is not holding the env var value.  
Just wanna understand why you need to store the env var value in a variable as the value is stored in an environment variable and u can access the env variable directly.

---

<div class="post-metadata">

**Author:** ![rjames](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/rjames/32/1656_2.png) [@rjames](https://discourse.getdbt.com/u/rjames)\
**Post date:** [April 25, 2023, 4:30pm UTC](https://discourse.getdbt.com/t/how-to-assign-value-of-environmental-variable-to-variable-in-project-yml-file/7814/3 "2023-04-25T16:30:03Z")

</div>

there is no use case for me. I’m just trying to understand if that’s a limitation. Thank you for checking.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/getdbt/original/1X/a7a7ca1fe379aaf90952b0e13118a817babcd14f.png) [@system](https://discourse.getdbt.com/u/system)\
**Post date:** [May 2, 2023, 4:30pm UTC](https://discourse.getdbt.com/t/how-to-assign-value-of-environmental-variable-to-variable-in-project-yml-file/7814/4 "2023-05-02T16:30:54Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
