TheProgramMAN123
TheProgramMAN123

Reputation: 487

os.environ.get() cannot find the variables, might be path related?

Edit: fixed typo, now I get a new error. It does run, but when I try to load the page I get an error instead.

So here is the code in

SQLALCHEMY_DATABASE_URI = os.environ.get('SQLALCHEMY_DATABASE_URI')

Here is the variable in my .bash_profile file:

export SQLALCHEMY_DATABASE_URI='sqlite:///site.db'

Here is the error

AttributeError: 'NoneType' object has no attribute 'drivername'

I have a .bash_profile file in home, in flask_blog_test in flaskblog and in the venv directory with the variable. But nothing works.

When I os.environ.get('PATH') in my config.py file I get the following:

/home/my_pc/running_python_projects/flask_blog_test/venv/bin:/home/my_pc/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

When I try to print the variable I obviously get nothing. Anyway to fix this?

Upvotes: 0

Views: 326

Answers (1)

ThiefMaster
ThiefMaster

Reputation: 318468

The code you posted is not the code that's actually running:

SQLALCHEMY_DATABASE_URI = os.environ.get('SQLALCHEMY_DATABASE_URI')
SQLALCHEMY_DATABASE_URI - os.environ.get('SQLALCHEMY_DATABASE_URI')
#                       ^

Replace the - with a =.

Upvotes: 1

Related Questions