dimmg dimmg - 1 year ago 198
Ini Question

.ini file load environment variable

I am using Alembic for migrations implementation in a

project. There is a
file where the database configs must be specified:

sqlalchemy.url = driver://user:password@host/dbname

Is there a way to specify the parameters from the environment variables? I've tried to load them in this way
but with no success. Thanks!

Answer Source

I've solved the problem by setting sqlalchemy.url in env.py as @dirn suggested.

config.set_main_option('sqlalchemy.url', <db_uri>) did the trick, where <db_uri> can be loaded from environment or config file.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download