Skip to main content

A simple way of using environment variables in TOML configs (via interpolation)

Project description

PyPI Status Build Status Code coverage Status License Status

envTOML is an answer to a fairly simple problem: including values from environment variables in TOML configuration files. In this way, it is very similar to both envyaml and varyaml which provide very similar functionality for YAML and which greatly inspired this small package.


Suppose we have the following configuration saved in config.toml

host = "$DB_HOST"
port = "$DB_PORT"
username = "$DB_USERNAME"
password = "$DB_PASSWORD"
name = "my_database"

with the environment variables being set to the following


this config can then be parsed with envTOML in the following way:

import envtoml

cfg = envtoml.load(open('./config.toml'))

# {'db': {'host': 'some-host.tld',
#   'port': 3306,
#   'username': 'user01',
#   'password': 'veryToughPas$w0rd',
#   'name': 'my_database'}}


As this project makes use of Poetry, after installing it the tests can be ran by executing the following from the project’s root directory:

poetry run nosetests tests

They can also be ran with coverage:

poetry run nosetests --with-coverage tests


Licensed under the MIT license (see LICENSE file for more details).

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for envtoml, version 0.1.2
Filename, size File type Python version Upload date Hashes
Filename, size envTOML-0.1.2-py3-none-any.whl (3.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size envTOML-0.1.2.tar.gz (3.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page