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)
On python 2.4, use the
pysqlitepackage. This is the exact same package that was added to the Python standard library in version 2.5, when it was renamed tosqlite3.As it is the same package, there are no differences in the API, and you only have to use a
tryexcept ImportErrortest: