From 1b06d5e6f6be8e567ce78c892c485af039830d7d Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Fri, 20 Jan 2017 18:21:15 -0500 Subject: [PATCH] Refs #23919 -- Removed pysqlite support (it's Python 2 only). --- django/contrib/gis/db/backends/spatialite/base.py | 13 ++++--------- django/db/backends/sqlite3/base.py | 15 ++------------- docs/ref/contrib/gis/install/index.txt | 6 +++--- docs/ref/databases.txt | 12 ------------ 4 files changed, 9 insertions(+), 37 deletions(-) diff --git a/django/contrib/gis/db/backends/spatialite/base.py b/django/contrib/gis/db/backends/spatialite/base.py index 1f03868945..799e9f1671 100644 --- a/django/contrib/gis/db/backends/spatialite/base.py +++ b/django/contrib/gis/db/backends/spatialite/base.py @@ -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) diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py index 07c4ceb1e7..2db7276e40 100644 --- a/django/db/backends/sqlite3/base.py +++ b/django/db/backends/sqlite3/base.py @@ -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 diff --git a/docs/ref/contrib/gis/install/index.txt b/docs/ref/contrib/gis/install/index.txt index cb919628d0..06990943ef 100644 --- a/docs/ref/contrib/gis/install/index.txt +++ b/docs/ref/contrib/gis/install/index.txt @@ -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 `. 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 `_ (for SpatiaLite). +for compiling the Python database adapters :ref:`psycopg2_kyngchaos` (for +PostGIS). .. note:: diff --git a/docs/ref/databases.txt b/docs/ref/databases.txt index 5ba10664d4..db622439f4 100644 --- a/docs/ref/databases.txt +++ b/docs/ref/databases.txt @@ -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 ---------------------------