Hi
dynaconf a layered configuration system for Python applications - with strong support for 12-factor applications and Flask app.config extension. It reads config data from various sources as files, databases, memory k:v storages and also vaults like vaultproject.io
Take a look https://github.com/rochacbruno/dynaconf
install Dynaconf in a Python 3 environment
# to use with settings.py, settings.json, .env or environment vars
pip3 install dynaconf
# to include support for more file formats
pip3 install dynaconf[yaml]
pip3 install dynaconf[toml]
pip3 install dynaconf[ini]
pip3 install dynaconf[redis]
pip3 install dynaconf[vault]
# for a complete installation
pip3 install dynaconf[all]
How does it work?
# import the unique dynaconf object
from dynaconf import settings
# access your config variables
Connect(user=settings.USERNAME, passwd=settings.PASSWD)
# You can provide defaults in case config is missing
Connect(user=settings('USERNAME', 'admin'), passwd=settings('PASSWD', 1234))
Where the values come from?
Dynaconf will look for variables in the following order (by default) and you can also customize the order of loaders.
Settings files files in the order: settings.{py|yaml|toml|ini|json}
.env file
exported Environment Variables
Remote storage servers
Multiple customizable sources
12factor recommended example (environment variables):
# put some variable in a .env file
echo "DYNACONF_USERNAME=admin" >> .env
# Or export directly
export DYNACONF_USERNAME=admin
export DYNACONF_PASSWD='@int 1234' # you can type the values!
Just read it
# import the unique dynaconf object
from dynaconf import settings
# access your config variables
Connect(user=settings.USERNAME, passwd=settings.PASSWD)
Take a look:https://github.com/rochacbruno/dynaconf