dj-database-url/setup.py

95 lines
3 KiB
Python
Raw Normal View History

2012-04-30 17:43:46 +00:00
# -*- coding: utf-8 -*-
"""
dj-database-url
~~~~~~~~~~~~~~~
2012-06-21 16:04:16 +00:00
.. image:: https://secure.travis-ci.org/kennethreitz/dj-database-url.png?branch=master
2016-02-03 23:34:29 +00:00
:target: http://travis-ci.org/kennethreitz/dj-database-url
2012-06-21 16:04:16 +00:00
2012-04-30 17:43:46 +00:00
This simple Django utility allows you to utilize the
`12factor <http://www.12factor.net/backing-services>`_ inspired
``DATABASE_URL`` environment variable to configure your Django application.
2016-02-03 23:34:29 +00:00
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),
2016-02-03 23:39:53 +00:00
Oracle, Oracle (GIS), and SQLite.
2016-02-03 23:34:29 +00:00
Installation
------------
Installation is simple::
$ pip install dj-database-url
2012-04-30 17:43:46 +00:00
Usage
-----
2012-06-21 16:04:16 +00:00
Configure your database in ``settings.py`` from ``DATABASE_URL``::
2016-02-03 23:34:29 +00:00
import dj_database_url
2012-06-21 16:04:16 +00:00
DATABASES['default'] = dj_database_url.config(conn_max_age=600, ssl_require=True)
2012-06-21 16:04:16 +00:00
2016-02-03 23:34:29 +00:00
Provide a default::
2012-06-21 16:04:16 +00:00
2016-02-03 23:34:29 +00:00
DATABASES['default'] = dj_database_url.config(default='postgres://...'}
Parse an arbitrary Database URL::
2012-06-21 16:04:16 +00:00
2016-02-03 23:34:29 +00:00
DATABASES['default'] = dj_database_url.parse('postgres://...', conn_max_age=600)
2012-04-30 17:43:46 +00:00
2016-02-03 23:34:29 +00:00
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.
2012-04-30 17:43:46 +00:00
"""
from setuptools import setup
setup(
name='dj-database-url',
version='0.5.0',
2012-04-30 17:43:46 +00:00
url='https://github.com/kennethreitz/dj-database-url',
license='BSD',
author='Kenneth Reitz',
author_email='me@kennethreitz.com',
description='Use Database URLs in your Django Application.',
long_description=__doc__,
py_modules=['dj_database_url'],
zip_safe=False,
include_package_data=True,
platforms='any',
classifiers=[
'Environment :: Web Environment',
2018-08-26 00:06:24 +00:00
'Framework :: Django',
'Framework :: Django :: 1.11',
'Framework :: Django :: 2.0',
'Framework :: Django :: 2.1',
2019-01-25 20:01:02 +00:00
'Framework :: Django :: 2.2',
2012-04-30 17:43:46 +00:00
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Software Development :: Libraries :: Python Modules',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
2016-02-03 23:35:06 +00:00
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
2019-01-25 19:44:08 +00:00
'Programming Language :: Python :: 3.6',
2019-01-25 20:11:31 +00:00
'Programming Language :: Python :: 3.7',
2012-04-30 17:43:46 +00:00
]
)