import pysqlite2 or import sqlite3?

MonkeeSage MonkeeSage at gmail.com
Sun Nov 25 06:32:21 EST 2007


I use the following for a progam I wrote using sqlite, to ensure
maximum compatibility (since the API is the same, importing them both
as 'sqlite' should be fine):

try:
  from sqlite3 import dbapi2 as sqlite # python 2.5
except:
  try:
    from pysqlite2 import dbapi2 as sqlite
  except:
    print 'This program requires pysqlite2\n',\
          'http://initd.org/tracker/pysqlite/'
    sys.exit(1)

Regards,
Jordan



More information about the Python-list mailing list