HBNetwork / python-decouple

Strict separation of config from code.
MIT License
2.82k stars 195 forks source link

config not working right #130

Closed dmtzs closed 2 years ago

dmtzs commented 2 years ago

Im trying to get my envvars in a file in the same part as the python file that im using for the correct credentials but im having an error and its that at the moment I use the config option always has the default value and doesnt find my .env file. Below an example of code:

import decouple as dc

asset = {
    "db_username": str(dc.config("DB_USERNAME_1")),
    "db_password": str(dc.config("DB_PASSWORD_1", default=None)),
    "db_name": str(dc.config("DB_1", default=None))
}

and printing the dictionary I receive the next values:

{'db_username': None, 'db_password': 'None', 'db_name': 'None'}

Of course should be printed the values stored in my .env file but always get the default value, i didnt change anything and before was working as expected but now is broken. I need to add that the .env file is in the same level as my python script.

Thank you for your support.

henriquebastos commented 2 years ago

I need to add that the .env file is in the same level as my python script.

Same level or any parent level. It won't work automatically for sibling directories.