Contact: fumanchu@aminus.org

Log in as guest/geniusql to create tickets

Changeset 160

Show
Ignore:
Timestamp:
09/04/07 04:55:51
Author:
fumanchu
Message:

Support for pysqlite2 (in versions of Python < 2.5, before it was built in).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/geniusql/providers/sqlite.py

    r159 r160  
    1313    import _sqlite3 as _sqlite 
    1414    _version = providers.Version(_sqlite.sqlite_version) 
    15     _cursor_required = True 
    16     _fetchall_required = True 
    17     _lastrowid_support = True 
    1815except ImportError: 
    1916    # Use _sqlite directly to avoid all of the DB-API overhead. 
    2017    # This will import the "old API for SQLite 3.x", 
    2118    # using e.g. pysqlite 1.1.7 
    22     import _sqlite 
    23     _version = providers.Version(_sqlite.sqlite_version()) 
    24     _cursor_required = False 
    25     _fetchall_required = False 
    26     _lastrowid_support = False 
    27  
     19    try: 
     20        # Is the single module on the python path? 
     21        import _sqlite 
     22    except ImportError: 
     23        # Try pysqlite2 
     24        from pysqlite2 import _sqlite 
     25    _version = _sqlite.sqlite_version 
     26    if callable(_version): 
     27        # Newer versions of pysqlite have a string instead of a function. 
     28        _version = _version() 
     29    _version = providers.Version(_version) 
     30 
     31_driver_version = providers.Version(getattr(_sqlite, "version", "1")) 
     32if _driver_version >= 2: 
     33    _cursor_required = True 
     34    _fetchall_required = True 
     35    _lastrowid_support = True 
     36else: 
     37    _cursor_required = True 
     38    _fetchall_required = True 
     39    _lastrowid_support = True 
    2840 
    2941# ESCAPE keyword was added Nov 2004, 1 month after 3.0.8 release. 
  • trunk/geniusql/test/test_sqlite.py

    r159 r160  
    1313        # This will import the "old API for SQLite 3.x", 
    1414        # using e.g. pysqlite 1.1.7 
    15         import _sqlite 
     15        try: 
     16            # Is the single module on the python path? 
     17            import _sqlite 
     18        except ImportError: 
     19            # Try pysqlite2 
     20            from pysqlite2 import _sqlite 
    1621    except ImportError: 
    1722        def run(memonly=False):