diff --git a/.travis.yml b/.travis.yml index 07cc253..b385ad7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,6 @@ python: - 2.5 - 2.6 - 2.7 - - 3.1 - 3.2 + - 3.3 script: make test diff --git a/README.rst b/README.rst index 2e0efc4..dc5bf51 100644 --- a/README.rst +++ b/README.rst @@ -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. diff --git a/dj_database_url.py b/dj_database_url.py index fe4ab1a..8e935ed 100644 --- a/dj_database_url.py +++ b/dj_database_url.py @@ -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', } diff --git a/test_dj_database_url.py b/test_dj_database_url.py index 08dc4e6..75ec700 100644 --- a/test_dj_database_url.py +++ b/test_dj_database_url.py @@ -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)