Skip to content
/ twelve Public

12factor inspired settings for a variety of backing services archetypes

License

Notifications You must be signed in to change notification settings

dstufft/twelve

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Twelve

Twelve is a utility for using 12factor inspired settings in Python. It provides a Configuration class which abstracts away pulling settings out of the environment and normalizing them and small adapters to make it easy to use those values in various popular frameworks.

There have been a few projects doing similar things, such as dj-database-url, dj-cache-url, and django-heroku-memcacheify. Each one of them handling the backing service configuration for a single archetype of service (database, cache, etc) and tied to a specific framework (and in one case, to a specific framework on a specific hosting platform).

Twelve attempts to provide a uniform and simple API to using 12factor inspired configuration without being tied to a specific archetype of backing service, nor to a single framework or hosting provider.

Basic Usage

# Setup Environment (Normally Done Externally to Configuration)
import os
os.environ["DATABASE_URL"] = "postgres://user:pass@hostname:5432/dbname"

# Load Twelve Configuration
import twelve
config = twelve.Configuration()

# Use Values
import psycopg2
conn = psycopg2.connect(
                    host=config.databases["default"]["host"],
                    port=config.databases["default"]["port"],
                    user=config.databases["default"]["user"],
                    password=config.databases["default"]["password"],
                    database=config.databases["default"]["name"],
                )

Basic Usage w/ Django Adapter

# Setup Environment (Normally Done Externally to Configuration)
import os
os.environ["DATABASE_URL"] = "postgres://user:pass@hostname:5432/dbname"

# Load Twelve Environment
import twelve
config = twelve.Configuration(adapter="django")

DATABASES = config.databases

About

12factor inspired settings for a variety of backing services archetypes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages