Skip to main content
https://secure.travis-ci.org/kennethreitz/dj-database-url.png?branch=master

This simple Django utility allows you to utilize the 12factor inspired DATABASE_URL environment variable to configure your Django application.

The dj_database_url.config method returns a Django database connection dictionary, populated with all the data specified in your URL. There is also a conn_max_age argument to easily enable Django’s connection pool.

If you’d rather not use an environment variable, you can pass a URL in directly instead to dj_database_url.parse.

Supported Databases

Support currently exists for PostgreSQL, PostGIS, MySQL, MySQL (GIS), Oracle, Oracle (GIS), and SQLite.

Installation

Installation is simple:

$ pip install dj-database-url

Usage

Configure your database in settings.py from DATABASE_URL:

import dj_database_url

DATABASES['default'] = dj_database_url.config(conn_max_age=600, ssl_require=True)

Provide a default:

DATABASES['default'] = dj_database_url.config(default='postgres://...'}

Parse an arbitrary Database URL:

DATABASES['default'] = dj_database_url.parse('postgres://...', conn_max_age=600)

The conn_max_age attribute is the lifetime of a database connection in seconds and is available in Django 1.6+. If you do not set a value, it will default to 0 which is Django’s historical behavior of using a new database connection on each request. Use None for unlimited persistent connections.

Release files for dj-database-url 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dj-database-url 0.5.0
File Size Uploaded
dj-database-url-0.5.0.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dj-database-url 0.5.0
File Interpreter ABI Platform
dj_database_url-0.5.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 11.0 kB

Release files / dj-database-url-0.5.0.tar.gz

Download URL dj-database-url-0.5.0.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
4aeaeb1f573c74835b0686a2b46b85990571159ffc21aa57ecd4d1e1cb334163
BLAKE2b-256 checksum
How to use checksums
01c498fbf678e810029be8078419f7bba626aafa2e81bc38748757db954c477c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / dj_database_url-0.5.0-py2.py3-none-any.whl

Download URL dj_database_url-0.5.0-py2.py3-none-any.whl
Size 5.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
851785365761ebe4994a921b433062309eb882fedd318e1b0fcecc607ed02da9
BLAKE2b-256 checksum
How to use checksums
d4a64b8578c1848690d0c307c7c0596af2077536c9ef2a04d42b00fabaa7e49d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

3.1.2

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.3.0

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

This release

0.5.0 This release

2 release files

0.4.2

2 release files

0.4.1

1 release file

0.4.0

1 release file

0.3.0

2 release files

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page