Ticket #17756: patch-feb2312@1646.diff
File patch-feb2312@1646.diff, 4.4 KB (added by , 13 years ago) |
---|
-
docs/ref/contrib/gis/install.txt
64 64 PostgreSQL GEOS, PROJ.4, PostGIS 8.1+ Requires PostGIS. 65 65 MySQL GEOS 5.x Not OGC-compliant; limited functionality. 66 66 Oracle GEOS 10.2, 11 XE not supported; not tested with 9. 67 SQLite GEOS, GDAL, PROJ.4, SpatiaLite 3.6.+ Requires SpatiaLite 2.3+, pys qlite2 2.5+, and Django 1.1.67 SQLite GEOS, GDAL, PROJ.4, SpatiaLite 3.6.+ Requires SpatiaLite 2.3+, pyspatialite2.6+ OR pysqlite2 2.5+ 68 68 ================== ============================== ================== ========================================================== 69 69 70 70 .. _geospatial_libs: … … 459 459 460 460 .. _pysqlite2: 461 461 462 463 pyspatialite 464 ^^^^^^^^^^^^ 465 466 Based almost entirely on pysqlite, this module primarily does one thing different: it build's it's own copy 467 of sqlite with spatialite built in.The simplest way to install is to use python package installer PIP: 468 469 $ pip install pyspatialite 470 462 471 pysqlite2 463 472 ^^^^^^^^^ 464 473 474 NOTE: Skip this step if you have already installed pyspatialite 475 465 476 Because SpatiaLite must be loaded as an external extension, it requires the 466 477 ``enable_load_extension`` method, which is only available in versions 2.5+. 467 478 Thus, download pysqlite2 2.6, and untar:: -
django/db/backends/sqlite3/base.py
22 22 from django.utils.timezone import is_aware, is_naive, utc 23 23 24 24 try: 25 from pyspatialite import dbapi2 as Database 26 except ImportError, exc: 25 27 try: 26 28 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) 32 35 33 36 34 37 DatabaseError = Database.DatabaseError … … 337 340 raise utils.DatabaseError, utils.DatabaseError(*tuple(e)), sys.exc_info()[2] 338 341 339 342 def convert_query(self, query): 340 return FORMAT_QMARK_REGEX.sub('?', query).replace('%%', '%')343 return FORMAT_QMARK_REGEX.sub('?', query).replace('%%', '%') 341 344 342 345 def _sqlite_extract(lookup_type, dt): 343 346 if dt is None: -
django/contrib/gis/db/backends/spatialite/base.py
15 15 def __init__(self, *args, **kwargs): 16 16 # Before we get too far, make sure pysqlite 2.5+ is installed. 17 17 if Database.version_info < (2, 5, 0): 18 raise ImproperlyConfigured('Only versions of pys qlite 2.5+ are '18 raise ImproperlyConfigured('Only versions of pyspatialite 2.6+ or pysqlite 2.5+ are ' 19 19 'compatible with SpatiaLite and GeoDjango.') 20 20 21 21 # Trying to find the location of the SpatiaLite library. … … 47 47 self.connection.enable_load_extension(True) 48 48 except AttributeError: 49 49 raise ImproperlyConfigured('The pysqlite library does not support C extension loading. ' 50 ' Both SQLite and pysqlite must be configuredto allow '50 'Install pyspatialite or configure SQLite and pysqlite to allow ' 51 51 'the loading of extensions to use SpatiaLite.' 52 52 ) 53 53