diff -r fa344eb7dd92 django/db/backends/sqlite3/base.py
a
|
b
|
|
11 | 11 | from django.db.backends.sqlite3.creation import DatabaseCreation |
12 | 12 | from django.db.backends.sqlite3.introspection import DatabaseIntrospection |
13 | 13 | from django.utils.safestring import SafeString |
| 14 | from django.conf import settings |
| 15 | import sys |
14 | 16 | |
| 17 | if sys.version_info < (2, 5, 0): |
| 18 | module = 'pysqlite2' |
| 19 | else: |
| 20 | module = 'sqlite3' |
| 21 | if hasattr(settings, 'DATABASE_OPTIONS'): |
| 22 | module = settings.DATABASE_OPTIONS.get('module', module) |
15 | 23 | try: |
16 | | try: |
17 | | from sqlite3 import dbapi2 as Database |
18 | | except ImportError, e1: |
19 | | from pysqlite2 import dbapi2 as Database |
| 24 | __import__(module + '.dbapi2') |
| 25 | Database = sys.modules[module + '.dbapi2'] |
20 | 26 | except ImportError, exc: |
21 | | import sys |
22 | 27 | 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 | 28 | raise ImproperlyConfigured, "Error loading %s module: %s" % (module, exc) |
29 | 29 | |
30 | 30 | try: |
… |
… |
|
163 | 163 | 'database': settings.DATABASE_NAME, |
164 | 164 | 'detect_types': Database.PARSE_DECLTYPES | Database.PARSE_COLNAMES, |
165 | 165 | } |
| 166 | self.options.pop('module', None) |
166 | 167 | kwargs.update(self.options) |
167 | 168 | self.connection = Database.connect(**kwargs) |
168 | 169 | # Register extract, date_trunc, and regexp functions. |