Code

Ticket #2772: patch_to_sqlite3_base.diff

File patch_to_sqlite3_base.diff, 894 bytes (added by ymasuda, 8 years ago)

patch to trunk/django/db/backends/sqlite3/base.py

Line 
1Index: db/backends/sqlite3/base.py
2===================================================================
3--- db/backends/sqlite3/base.py (revision 3769)
4+++ db/backends/sqlite3/base.py (working copy)
5@@ -3,12 +3,21 @@
6 """
7 
8 from django.db.backends import util
9+from sys import hexversion
10+
11+modname = 'sqlite3'
12 try:
13-    from pysqlite2 import dbapi2 as Database
14+    if hexversion < 0x020500a1:
15+        modname = 'pysqlite2'
16+        from pysqlite2 import dbapi2 as Database
17+    else:
18+        from sqlite3 import dbapi2 as Database
19 except ImportError, e:
20     from django.core.exceptions import ImproperlyConfigured
21-    raise ImproperlyConfigured, "Error loading pysqlite2 module: %s" % e
22+    raise ImproperlyConfigured, "Error loading %s module: %s" % (modname, e)
23+del modname
24 
25+
26 DatabaseError = Database.DatabaseError
27 
28 Database.register_converter("bool", lambda s: str(s) == '1')