Refs #23919 -- Removed pysqlite support (it's Python 2 only).

This commit is contained in:
Tim Graham 2017-01-20 18:21:15 -05:00
parent 289fc1bfa5
commit 1b06d5e6f6
4 changed files with 9 additions and 37 deletions

View File

@ -4,7 +4,7 @@ from ctypes.util import find_library
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.db.backends.sqlite3.base import (
Database, DatabaseWrapper as SQLiteDatabaseWrapper, SQLiteCursorWrapper,
DatabaseWrapper as SQLiteDatabaseWrapper, SQLiteCursorWrapper,
)
from django.utils import six
@ -24,11 +24,6 @@ class DatabaseWrapper(SQLiteDatabaseWrapper):
ops_class = SpatiaLiteOperations
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 '
'compatible with SpatiaLite and GeoDjango.')
# Trying to find the location of the SpatiaLite library.
# Here we are figuring out the path to the SpatiaLite library
# (`libspatialite`). If it's not in the system library path (e.g., it
@ -50,9 +45,9 @@ class DatabaseWrapper(SQLiteDatabaseWrapper):
conn.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 '
'the loading of extensions to use SpatiaLite.')
'SpatiaLite requires SQLite to be configured to allow '
'extension loading.'
)
# Loading the SpatiaLite library extension on the connection, and returning
# the created cursor.
cur = conn.cursor(factory=SQLiteCursorWrapper)

View File

@ -1,12 +1,10 @@
"""
SQLite3 backend for django.
Works with either the pysqlite2 module or the sqlite3 module in the
standard library.
SQLite3 backend for the sqlite3 module in the standard library.
"""
import decimal
import re
import warnings
from sqlite3 import dbapi2 as Database
import pytz
@ -20,15 +18,6 @@ from django.utils.dateparse import (
)
from django.utils.encoding import force_text
try:
try:
from pysqlite2 import dbapi2 as Database
except ImportError:
from sqlite3 import dbapi2 as Database
except ImportError as exc:
raise ImproperlyConfigured("Error loading either pysqlite2 or sqlite3 modules (tried in that order): %s" % exc)
# Some of these import sqlite3, so import them after checking if it's installed.
from .client import DatabaseClient # isort:skip
from .creation import DatabaseCreation # isort:skip
from .features import DatabaseFeatures # isort:skip

View File

@ -61,7 +61,7 @@ Database Library Requirements Supported Versions Notes
PostgreSQL GEOS, GDAL, PROJ.4, PostGIS 9.3+ Requires PostGIS.
MySQL GEOS, GDAL 5.5+ Not OGC-compliant; :ref:`limited functionality <mysql-spatial-limitations>`.
Oracle GEOS, GDAL 11.2+ XE not supported.
SQLite GEOS, GDAL, PROJ.4, SpatiaLite 3.6.+ Requires SpatiaLite 4.0+, pysqlite2 2.5+
SQLite GEOS, GDAL, PROJ.4, SpatiaLite 3.6.+ Requires SpatiaLite 4.0+
================== ============================== ================== =========================================
See also `this comparison matrix`__ on the OSGeo Wiki for
@ -268,8 +268,8 @@ KyngChaos packages
William Kyngesburye provides a number of `geospatial library binary packages`__
that make it simple to get GeoDjango installed on OS X without compiling
them from source. However, the `Apple Developer Tools`_ are still necessary
for compiling the Python database adapters :ref:`psycopg2_kyngchaos` (for PostGIS)
and `pysqlite2 <https://pypi.python.org/pypi/pysqlite>`_ (for SpatiaLite).
for compiling the Python database adapters :ref:`psycopg2_kyngchaos` (for
PostGIS).
.. note::

View File

@ -663,18 +663,6 @@ substring filtering.
.. _documented at sqlite.org: https://www.sqlite.org/faq.html#q18
.. _using-newer-versions-of-pysqlite:
Using newer versions of the SQLite DB-API 2.0 driver
----------------------------------------------------
Django will use a ``pysqlite2`` module in preference to ``sqlite3`` as shipped
with the Python standard library if it finds one is available.
This provides the ability to upgrade both the DB-API 2.0 interface or SQLite 3
itself to versions newer than the ones included with your particular Python
binary distribution, if needed.
"Database is locked" errors
---------------------------