Kaydet (Commit) f36e5d68 authored tarafından Sergey Fedoseev's avatar Sergey Fedoseev Kaydeden (comit) Tim Graham

Used sqlite3.Connection.load_extension() instead of query execution for SpatiaLite loading.

üst 0dbcd0e8
......@@ -3,7 +3,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 (
DatabaseWrapper as SQLiteDatabaseWrapper, SQLiteCursorWrapper,
DatabaseWrapper as SQLiteDatabaseWrapper,
)
from .client import SpatiaLiteClient
......@@ -46,16 +46,13 @@ class DatabaseWrapper(SQLiteDatabaseWrapper):
'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)
# Load the SpatiaLite library extension on the connection.
try:
cur.execute("SELECT load_extension(%s)", (self.spatialite_lib,))
conn.load_extension(self.spatialite_lib)
except Exception as exc:
raise ImproperlyConfigured(
'Unable to load the SpatiaLite library extension "%s"' % self.spatialite_lib
) from exc
cur.close()
return conn
def prepare_database(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment