Ticket #17756: patch-feb2312@1646.diff

File patch-feb2312@1646.diff, 4.4 KB (added by danols, 4 years ago)

Code + Doc patch

  • docs/ref/contrib/gis/install.txt

     
    6464PostgreSQL          GEOS, PROJ.4, PostGIS           8.1+                Requires PostGIS.
    6565MySQL               GEOS                            5.x                 Not OGC-compliant; limited functionality.
    6666Oracle              GEOS                            10.2, 11            XE not supported; not tested with 9.
    67 SQLite              GEOS, GDAL, PROJ.4, SpatiaLite  3.6.+               Requires SpatiaLite 2.3+, pysqlite2 2.5+, and Django 1.1.
     67SQLite              GEOS, GDAL, PROJ.4, SpatiaLite  3.6.+               Requires SpatiaLite 2.3+, pyspatialite2.6+ OR pysqlite2 2.5+
    6868==================  ==============================  ==================  ==========================================================
    6969
    7070.. _geospatial_libs:
     
    459459
    460460.. _pysqlite2:
    461461
     462
     463pyspatialite
     464^^^^^^^^^^^^
     465
     466Based almost entirely on pysqlite, this module primarily does one thing different: it build's it's own copy
     467of sqlite with spatialite built in.The simplest way to install is to use python package installer PIP:
     468
     469    $ pip install pyspatialite
     470
    462471pysqlite2
    463472^^^^^^^^^
    464473
     474NOTE: Skip this step if you have already installed pyspatialite
     475
    465476Because SpatiaLite must be loaded as an external extension, it requires the
    466477``enable_load_extension`` method, which is only available in versions 2.5+.
    467478Thus, download pysqlite2 2.6, and untar::
  • django/db/backends/sqlite3/base.py

     
    2222from django.utils.timezone import is_aware, is_naive, utc
    2323
    2424try:
     25    from pyspatialite import dbapi2 as Database
     26except ImportError, exc:
    2527    try:
    2628        from pysqlite2 import dbapi2 as Database
    27     except ImportError, e1:
    28         from sqlite3 import dbapi2 as Database
    29 except ImportError, exc:
    30     from django.core.exceptions import ImproperlyConfigured
    31     raise ImproperlyConfigured("Error loading either pysqlite2 or sqlite3 modules (tried in that order): %s" % exc)
     29    except ImportError, exc:
     30        try:
     31            from sqlite3 import dbapi2 as Database
     32        except ImportError, exc:
     33            from django.core.exceptions import ImproperlyConfigured
     34            raise ImproperlyConfigured("Error loading either pyspatialite, pysqlite2 or sqlite3 modules (tried in that order): %s" % exc)
    3235
    3336
    3437DatabaseError = Database.DatabaseError
     
    337340            raise utils.DatabaseError, utils.DatabaseError(*tuple(e)), sys.exc_info()[2]
    338341
    339342    def convert_query(self, query):
    340         return FORMAT_QMARK_REGEX.sub('?', query).replace('%%','%')
     343        return FORMAT_QMARK_REGEX.sub('?', query).replace('%%', '%')
    341344
    342345def _sqlite_extract(lookup_type, dt):
    343346    if dt is None:
  • django/contrib/gis/db/backends/spatialite/base.py

     
    1515    def __init__(self, *args, **kwargs):
    1616        # Before we get too far, make sure pysqlite 2.5+ is installed.
    1717        if Database.version_info < (2, 5, 0):
    18             raise ImproperlyConfigured('Only versions of pysqlite 2.5+ are '
     18            raise ImproperlyConfigured('Only versions of pyspatialite 2.6+ or pysqlite 2.5+ are '
    1919                                       'compatible with SpatiaLite and GeoDjango.')
    2020
    2121        # Trying to find the location of the SpatiaLite library.
     
    4747                self.connection.enable_load_extension(True)
    4848            except AttributeError:
    4949                raise ImproperlyConfigured('The pysqlite library does not support C extension loading. '
    50                                            'Both SQLite and pysqlite must be configured to allow '
     50                                           'Install pyspatialite or configure SQLite and pysqlite to allow '
    5151                                           'the loading of extensions to use SpatiaLite.'
    5252                                           )
    5353
Back to Top