Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixed #17756 -- Added pyspatialite support #198

Closed
wants to merge 1 commit into from

2 participants

@danielsokolowski

And updated docs to include installation instruction for pyspatiliate
and that it can be used in lieu of pysqlite.

@danielsokolowski danielsokolowski Fixed #17756 -- Added pyspatialite support
Updated docs to include installation instruction for pyspatiliate
and that it can be used in lieu of pysqlite.
7b60d21
@akaariai
Collaborator

I'm closing this pull request as the patch is not ready for merge. See the ticket for details. Once the issues are resolved, please reopen the request.

@akaariai akaariai closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 10, 2012
  1. @danielsokolowski

    Fixed #17756 -- Added pyspatialite support

    danielsokolowski authored
    Updated docs to include installation instruction for pyspatiliate
    and that it can be used in lieu of pysqlite.
This page is out of date. Refresh to see the latest.
View
4 django/contrib/gis/db/backends/spatialite/base.py
@@ -15,7 +15,7 @@ class DatabaseWrapper(SQLiteDatabaseWrapper):
def __init__(self, *args, **kwargs):
# Before we get too far, make sure pysqlite 2.5+ is installed.
if Database.version_info < (2, 5, 0):
- raise ImproperlyConfigured('Only versions of pysqlite 2.5+ are '
+ raise ImproperlyConfigured('Only versions of pyspatialite 2.6+ or pysqlite 2.5+ are '
'compatible with SpatiaLite and GeoDjango.')
# Trying to find the location of the SpatiaLite library.
@@ -47,7 +47,7 @@ def _cursor(self):
self.connection.enable_load_extension(True)
except AttributeError:
raise ImproperlyConfigured('The pysqlite library does not support C extension loading. '
- 'Both SQLite and pysqlite must be configured to allow '
+ 'Install pyspatialite or configure SQLite and pysqlite to allow '
'the loading of extensions to use SpatiaLite.'
)
View
19 django/db/backends/sqlite3/base.py
@@ -24,13 +24,16 @@
from django.utils import timezone
try:
- try:
- from pysqlite2 import dbapi2 as Database
- except ImportError:
- from sqlite3 import dbapi2 as Database
-except ImportError as exc:
- from django.core.exceptions import ImproperlyConfigured
- raise ImproperlyConfigured("Error loading either pysqlite2 or sqlite3 modules (tried in that order): %s" % exc)
+ from pyspatialite import dbapi2 as Database
+except ImportError, exc:
+ try:
+ from pysqlite2 import dbapi2 as Database
+ except ImportError, exc:
+ try:
+ from sqlite3 import dbapi2 as Database
+ except ImportError, exc:
+ from django.core.exceptions import ImproperlyConfigured
+ raise ImproperlyConfigured("Error loading either pyspatialite, pysqlite2 or sqlite3 modules (attempted in that order): %s" % exc)
DatabaseError = Database.DatabaseError
@@ -355,7 +358,7 @@ def executemany(self, query, param_list):
raise utils.DatabaseError, utils.DatabaseError(*tuple(e)), sys.exc_info()[2]
def convert_query(self, query):
- return FORMAT_QMARK_REGEX.sub('?', query).replace('%%','%')
+ return FORMAT_QMARK_REGEX.sub('?', query).replace('%%', '%')
def _sqlite_extract(lookup_type, dt):
if dt is None:
View
41 docs/ref/contrib/gis/install.txt
@@ -60,14 +60,14 @@ The geospatial libraries required for a GeoDjango installation depends
on the spatial database used. The following lists the library requirements,
supported versions, and any notes for each of the supported database backends:
-================== ============================== ================== ==========================================================
+================== ============================== ================== ============================================================
Database Library Requirements Supported Versions Notes
-================== ============================== ================== ==========================================================
+================== ============================== ================== ============================================================
PostgreSQL GEOS, PROJ.4, PostGIS 8.1+ Requires PostGIS.
MySQL GEOS 5.x Not OGC-compliant; limited functionality.
Oracle GEOS 10.2, 11 XE not supported; not tested with 9.
-SQLite GEOS, GDAL, PROJ.4, SpatiaLite 3.6.+ Requires SpatiaLite 2.3+, pysqlite2 2.5+, and Django 1.1.
-================== ============================== ================== ==========================================================
+SQLite GEOS, GDAL, PROJ.4, SpatiaLite 3.6.+ Requires SpatiaLite 2.3+, pyspatialite2.6+ OR pysqlite2 2.5+
+================== ============================== ================== ============================================================
.. _geospatial_libs:
@@ -461,9 +461,30 @@ __ http://www.gaia-gis.it/gaia-sins/libspatialite-sources/
.. _pysqlite2:
+
+pyspatialite
+^^^^^^^^^^^^
+
+Based almost entirely on pysqlite, this module primarily does one thing different: it build's it's own copy
+of sqlite with spatialite built in. The simplest way to install is to use python package installer PIP:
+
+ $ pip install pyspatialite
+
+note::
+
+ The installation might fail during compiling if GEOS, GDAL, PROJ.4 development header files are missing.
+ Use your systems package installer to install these; on a Debian/Ubuntu run following command::
+
+ $ aptitude install libgeos-dev
+
+
+
+
pysqlite2
^^^^^^^^^
+NOTE: Skip this step if you have already installed pyspatialite.
+
Because SpatiaLite must be loaded as an external extension, it requires the
``enable_load_extension`` method, which is only available in versions 2.5+.
Thus, download pysqlite2 2.6, and untar::
@@ -1144,6 +1165,18 @@ Debian 5.0 . Thus when :ref:`spatialdb_template` either:
.. _windows:
+6.0 (Squeeze)
+^^^^^^^^^^^^^
+
+GeoDjango + SQlite (SpatiaLite) Database
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+To install GEOS, GDAL, PROJ.4, SpatiaLite execute following command - you may want to adjust for newer versions::
+
+ $ aptitude install libgeos-3.2.2 libgeos-dev proj libgdal1-1.6.0
+ $ pip install pyspatialite
+
+
Windows
-------
Something went wrong with that request. Please try again.