From 0d6b7e4a884b0c582ac03bc7353d406e418a8873 Mon Sep 17 00:00:00 2001 From: Milan Broum Date: Sun, 3 May 2015 18:41:34 +0100 Subject: [PATCH] [1.8.x] Allowed using the sqlite3 backend as much as possible without _sqlite3. The inner import was dropped during the reorganizing of the database backends in commit 28308078f397d1de36fd0da417ac7da2544ba12d. Backport of 95058606c89ba2dc95205487fa837ec39cf41ed5 from master --- django/db/backends/sqlite3/schema.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/django/db/backends/sqlite3/schema.py b/django/db/backends/sqlite3/schema.py index 5a21af74ac..d68312bcc3 100644 --- a/django/db/backends/sqlite3/schema.py +++ b/django/db/backends/sqlite3/schema.py @@ -1,4 +1,3 @@ -import _sqlite3 # isort:skip import codecs import copy from decimal import Decimal @@ -14,6 +13,10 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor): sql_create_inline_fk = "REFERENCES %(to_table)s (%(to_column)s)" def quote_value(self, value): + # The backend "mostly works" without this function and there are use + # cases for compiling Python without the sqlite3 libraries (e.g. + # security hardening). + import _sqlite3 try: value = _sqlite3.adapt(value) except _sqlite3.ProgrammingError: