Merge pull request #25 from waveaccounting/master

Add MySQL (GIS) support
This commit is contained in:
Kenneth Reitz 2014-01-08 12:19:59 -08:00
commit 86984deace
4 changed files with 18 additions and 5 deletions

View file

@ -3,6 +3,6 @@ python:
- 2.5
- 2.6
- 2.7
- 3.1
- 3.2
- 3.3
script: make test

View file

@ -12,10 +12,10 @@ This simple Django utility allows you to utilize the
Usage
-----
Configure your database in ``settings.py`` from ``DATABASE_URL``
Configure your database in ``settings.py`` from ``DATABASE_URL``
(``default`` is optional)::
DATABASES = {'default': dj_database_url.config(default='postgres://...')}
DATABASES = {'default': dj_database_url.config(default='postgres://...')}
Parse an arbitrary Database URL::
@ -24,7 +24,7 @@ Parse an arbitrary Database URL::
Supported databases
-------------------
Support currently exists for PostgreSQL, PostGIS, MySQL and SQLite.
Support currently exists for PostgreSQL, PostGIS, MySQL, MySQL (GIS) and SQLite.
SQLite connects to file based databases. The same URL format is used, omitting
the hostname, and using the "file" portion as the filename of the database.

View file

@ -16,6 +16,7 @@ urlparse.uses_netloc.append('pgsql')
urlparse.uses_netloc.append('postgis')
urlparse.uses_netloc.append('mysql')
urlparse.uses_netloc.append('mysql2')
urlparse.uses_netloc.append('mysqlgis')
urlparse.uses_netloc.append('spatialite')
urlparse.uses_netloc.append('sqlite')
@ -28,8 +29,9 @@ SCHEMES = {
'postgis': 'django.contrib.gis.db.backends.postgis',
'mysql': 'django.db.backends.mysql',
'mysql2': 'django.db.backends.mysql',
'mysqlgis': 'django.contrib.gis.db.backends.mysql',
'spatialite': 'django.contrib.gis.db.backends.spatialite',
'sqlite': 'django.db.backends.sqlite3'
'sqlite': 'django.db.backends.sqlite3',
}

View file

@ -34,6 +34,17 @@ class DatabaseTestSuite(unittest.TestCase):
assert url['PASSWORD'] == 'wegauwhgeuioweg'
assert url['PORT'] == 5431
def test_mysql_gis_parsing(self):
url = 'mysqlgis://uf07k1i6d8ia0v:wegauwhgeuioweg@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722r2kuvn'
url = dj_database_url.parse(url)
assert url['ENGINE'] == 'django.contrib.gis.db.backends.mysql'
assert url['NAME'] == 'd8r82722r2kuvn'
assert url['HOST'] == 'ec2-107-21-253-135.compute-1.amazonaws.com'
assert url['USER'] == 'uf07k1i6d8ia0v'
assert url['PASSWORD'] == 'wegauwhgeuioweg'
assert url['PORT'] == 5431
def test_cleardb_parsing(self):
url = 'mysql://bea6eb025ca0d8:69772142@us-cdbr-east.cleardb.com/heroku_97681db3eff7580?reconnect=true'
url = dj_database_url.parse(url)