Ticket #9628: use-pysqlite2-if-newer.diff

File use-pysqlite2-if-newer.diff, 1.2 KB (added by mdh, 16 years ago)

A first patch to use whichever of sqlite3 and pysqlite2 is newer.

  • django/db/backends/sqlite3/base.py

     
    33
    44Python 2.3 and 2.4 require pysqlite2 (http://pysqlite.org/).
    55
    6 Python 2.5 and later use the sqlite3 module in the standard library.
     6Python 2.5 and later use the sqlite3 module in the standard library,
     7unless a newer version of pysqlite2 is installed.
    78"""
    89
    910from django.db.backends import *
     
    1112from django.db.backends.sqlite3.creation import DatabaseCreation
    1213from django.db.backends.sqlite3.introspection import DatabaseIntrospection
    1314
    14 try:
     15Database = None
     16for pkg in ['sqlite3','pysqlite2']:
    1517    try:
    16         from sqlite3 import dbapi2 as Database
    17     except ImportError, e1:
    18         from pysqlite2 import dbapi2 as Database
    19 except ImportError, exc:
     18        mod = __import__(pkg, {}, {}, ['dbapi2'])
     19        if not Database or mod.dbapi2.version_info > Database.version_info:
     20            Database = mod.dbapi2
     21    except ImportError:
     22        pass
     23if not Database:
    2024    import sys
    2125    from django.core.exceptions import ImproperlyConfigured
    2226    if sys.version_info < (2, 5, 0):
Back to Top