Skip to main content

Add service URL parsing support for environs

Project description


environs-serviceurl is a Python library that extends the environs library with support for turning service urls like postgres://user:pass@host:port/database into Python dictionaries.


$ pip install environs-serviceurl


# export DATABASE_URL=postgres://
# export REDIS_URL=redis://

from environs import Env
from environs_serviceurl import service_url

env = Env()
env.add_parser('service_url', service_url)

# Parse a service url.
postgres_config = env.service_url('DATABASE_URL')
# {'host': '',
#  'port': 5432,
#  'user': 'me',
#  'password': 'sekrit',
#  'extras': 'catpics'}

# Give the extras a specific name
postgres_config = env.service_url('DATABASE_URL', extras_name='database')
# {'host': '',
#  'port': 5432,
#  'user': 'me',
#  'password': 'sekrit',
#  'database': 'catpics'}

# Parse a service url with defaults, using query params for extra values.
redis_config = env.service_url('REDIS_URL', 'redis://localhost/', defaults={
    'host': '', 'port': 6379, 'dbid': 0})
# {'host': '',
#  'port': 6379,
#  'user': None,
#  'password': None,
#  'extras': None,
#  'dbid': '3'}


There’s currently no way to do casting on any extras or query string paramaters. They will always be returned as string types.


MIT. See the LICENSE file for 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 environs-serviceurl, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size environs_serviceurl-1.0.1-py2.py3-none-any.whl (4.9 kB) File type Wheel Python version 2.7 Upload date Hashes View
Filename, size environs-serviceurl-1.0.1.tar.gz (4.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