Skip to content

Commit

Permalink
v0.5.0
Browse files Browse the repository at this point in the history
Signed-off-by: Kenneth Reitz <me@kennethreitz.org>
  • Loading branch information
kennethreitz committed Mar 1, 2018
1 parent d94d395 commit de91c7d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions dj_database_url.py
Expand Up @@ -44,20 +44,20 @@
}


def config(env=DEFAULT_ENV, default=None, engine=None, conn_max_age=0):
def config(env=DEFAULT_ENV, default=None, engine=None, conn_max_age=0, ssl_require=False):
"""Returns configured DATABASE dictionary from DATABASE_URL."""

config = {}

s = os.environ.get(env, default)

if s:
config = parse(s, engine, conn_max_age)
config = parse(s, engine, conn_max_age, ssl_require)

return config


def parse(url, engine=None, conn_max_age=0):
def parse(url, engine=None, conn_max_age=0, ssl_require=False):
"""Parses a database URL."""

if url == 'sqlite://:memory:':
Expand Down Expand Up @@ -124,6 +124,9 @@ def parse(url, engine=None, conn_max_age=0):

options[key] = values[-1]

if ssl_require:
options['sslmode'] = 'require'

# Support for Postgres Schema URLs
if 'currentSchema' in options and engine in (
'django.contrib.gis.db.backends.postgis',
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Expand Up @@ -37,7 +37,7 @@
import dj_database_url
DATABASES['default'] = dj_database_url.config(conn_max_age=600)
DATABASES['default'] = dj_database_url.config(conn_max_age=600, ssl_require=True)
Provide a default::
Expand All @@ -59,7 +59,7 @@

setup(
name='dj-database-url',
version='0.4.1',
version='0.5.0',
url='https://github.com/kennethreitz/dj-database-url',
license='BSD',
author='Kenneth Reitz',
Expand Down

0 comments on commit de91c7d

Please sign in to comment.