Skip to main content

Application configuration from environment variables made easy

Project description

https://img.shields.io/pypi/v/environconfig.svg https://img.shields.io/pypi/pyversions/environconfig.svg https://travis-ci.org/buguroo/environconfig.svg?branch=master

environconfig allows you to use environment variables in Python with a declarative syntax.

A quick example:

from environconfig import EnvironConfig
from environconfig import StringVar, IntVar

class DBCfg(EnvironConfig):
    """Database configuration from the environment."""
    HOSTNAME = StringVar(default='localhost')
    PORT = IntVar(default=3306)
    USERNAME = StringVar()
    PASSWORD = StringVar()
    CHARSET = StringVar(default='utf8mb4')
    NAME = StringVar(default='mydatabase')

# Now you can start using it
connection = pymysql.connect(host=DBCfg.HOSTNAME,
                             user=DBCfg.USERNAME,
                             password=DBCfg.PASSWORD,
                             db=DBCfg.NAME,
                             charset=DBCfg.CHARSET,
                             cursorclass=pymysql.cursors.DictCursor)

You can check more examples in the examples directory.

Features

  • Built-in basic types: String, Bool, Int, Float…

  • Easy Customizable: CustomVar (just pass a callable to make the conversion)

  • No mocking necessary for testing: Just instantiate your config with a dictionary.

  • Easy build complex constructions with environment data: See MethodVar

Collaboration

  • We are always open to pull requests and accept new var types.

Project details


Download files

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

Source Distribution

environconfig-1.7.0.tar.gz (4.2 kB view details)

Uploaded Source

File details

Details for the file environconfig-1.7.0.tar.gz.

File metadata

  • Download URL: environconfig-1.7.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for environconfig-1.7.0.tar.gz
Algorithm Hash digest
SHA256 06c50d8a3a7e73404276ee5b47539f41d5490409edeba64c40ed748d2daeea20
MD5 e31daecdc75acdcf6981492ee6d07164
BLAKE2b-256 bdda311afb542162536d4cf19a0e85a5e9eb462f4a8f1dc898fefe9b5524fd8b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page