Opened 18 years ago
Closed 18 years ago
#2772 closed enhancement (fixed)
[patch] Add support for standard sqlite3 module
Reported by: | ymasuda[at]ethercube.com | Owned by: | Malcolm Tredinnick |
---|---|---|---|
Component: | contrib.admin | Version: | |
Severity: | normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Starting with Python 2.5, SQLite binding was introduced as sqlite3 standard module which is
mostly identical to pysqlite2. The attached diff allows to import sqlite3 instead of pysqlite3
if sys.hexversion is greater than 0x020500a1 (Python 2.5a1).
This integration was tested under tests/runtest.py with #2771 patch.
Attachments (2)
Change History (8)
by , 18 years ago
Attachment: | patch_to_sqlite3_base.diff added |
---|
comment:1 by , 18 years ago
Summary: | Add support for standard sqlite3 module → [patch] Add support for standard sqlite3 module |
---|
prepended [patch] to the summary.
comment:2 by , 18 years ago
Maybe a better way to handle this would be what we do with threading -- try to import the 2.5 standard module, and if it tosses an ImportError
, catch that and import the pysqlite2
module instead.
comment:3 by , 18 years ago
Then, how about like this:
try: try: # (*explicitly installed*) pysqlite2 succeeds from pysqlite2 import dbapi2 as Database except ImportError, e: # fallback to sqlite3 from sqlite3 import dbapi2 as Database except ImportError, e: from django.core.exceptions import ImproperlyConfigured raise ImproperlyConfigured, "Error loading module: %s" % e
comment:4 by , 18 years ago
Owner: | changed from | to
---|
The second approach looks better, although I would rather try to import the standard Python module (sqlite3) first and then fallback. That fits in more with the trend to try to do the right thing first and fallback if we need a backwards-compatiblity feature that is common throughout Python's core.
I need to get a Python 2.5 build done and then I'll get this in.
comment:5 by , 18 years ago
Thanks ubernostrum and mtredinnick for comments.
Here I post a revised version of the patch: using nested try...except, and sqlite3 first then pysqlite2.
comment:6 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
patch to trunk/django/db/backends/sqlite3/base.py