Manage your app configuration using env variables
Project description
Envia
Did you ever lose track of all environment variables you can use to configure a project? Envia is a simple utility that allows you to group them together.
Installation
pip install envia
Usage
You can use Envia as follows
# app/config.py
from envia import EnvVar
APP_DB_VENDOR = EnvVar("APP_DB_VENDOR", default="postgres")
APP_DB_PORT = EnvVar("APP_DB_PORT", default="5432")
APP_DB_HOST = EnvVar("APP_DB_HOST")
# require() can be used to ensure early failure.
# This fails if APP_REQUIRED_VAR is not set
APP_REQUIRED_VAR = EnvVar("APP_REQUIRED_VAR").require()
To use the environment values you can do
# app/db.py
import app.config as cfg
def connect():
vendor = cfg.APP_DB_VENDOR.get_required()
port = cfg.APP_DB_PORT.get_required()
# This fails APP_DB_HOST is not set
host = cfg.APP_DB_HOST.get_required()
# This returns None if APP_DB_HOST is not set
host = cfg.APP_DB_HOST.require()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
envia-0.0.2.tar.gz
(4.5 kB
view hashes)
Built Distribution
envia-0.0.2-py3-none-any.whl
(5.1 kB
view hashes)