diff -r 08fa6b05f9ea django/db/backends/sqlite3/base.py
a
|
b
|
|
3 | 3 | |
4 | 4 | Python 2.3 and 2.4 require pysqlite2 (http://pysqlite.org/). |
5 | 5 | |
6 | | Python 2.5 and later use the sqlite3 module in the standard library. |
| 6 | Python 2.5 and later use the sqlite3 module in the standard library, |
| 7 | unless a newer version of pysqlite2 is installed. |
7 | 8 | """ |
8 | 9 | |
9 | 10 | from django.db.backends import * |
… |
… |
|
11 | 12 | from django.db.backends.sqlite3.creation import DatabaseCreation |
12 | 13 | from django.db.backends.sqlite3.introspection import DatabaseIntrospection |
13 | 14 | from django.utils.safestring import SafeString |
| 15 | import sys |
14 | 16 | |
15 | | try: |
| 17 | Database = None |
| 18 | for pkg in ['sqlite3','pysqlite2']: |
16 | 19 | try: |
17 | | from sqlite3 import dbapi2 as Database |
18 | | except ImportError, e1: |
19 | | from pysqlite2 import dbapi2 as Database |
20 | | except ImportError, exc: |
21 | | import sys |
| 20 | mod = __import__(pkg + '.dbapi2') |
| 21 | if not Database or mod.dbapi2.version_info > Database.version_info: |
| 22 | Database = sys.modules[pkg + '.dbapi2'] |
| 23 | except ImportError, exc: |
| 24 | pass |
| 25 | if not Database: |
22 | 26 | from django.core.exceptions import ImproperlyConfigured |
23 | | if sys.version_info < (2, 5, 0): |
24 | | module = 'pysqlite2' |
25 | | else: |
26 | | module = 'sqlite3' |
27 | | exc = e1 |
28 | | raise ImproperlyConfigured, "Error loading %s module: %s" % (module, exc) |
| 27 | raise ImproperlyConfigured, "Error loading %s module: %s" % (pkg, exc) |
29 | 28 | |
30 | 29 | try: |
31 | 30 | import decimal |