Supporting sqlite and sqlite3
python, sqlite
Solution
On python 2.4, use the `pysqlite` package. This is the exact same package that was added to the Python standard library in version 2.5, when it was renamed to `sqlite3`.
As it is the same package, there are no differences in the API, and you only have to use a `try` `except ImportError` test:
try:
import sqlite3
except ImportError:
from pysqlite2 import dbapi2 as sqlite3
Problem
I have an application that needs to support Python 2.4 and 2.6. With 2.6, sqlite3 replaces sqlite. Is there much else I need to worry about other than `paramstyle` differences? Is this a decent way of handling that? ``` try: import sqlite3 as sqlite except ImportError: import sqlite ... if sqlite.paramstyle == 'qmark': query = 'SELECT foo FROM bar where baz = ?' else: query = 'SELECT foo FROM bar where baz = %s' cursor.execute(query, params) ```