[portland] Python-2.5.1 and SQLite3

jason kirtland jek at discorporate.us
Mon Nov 12 20:43:10 CET 2007

Rich Shepard wrote:
> On Mon, 12 Nov 2007, jason kirtland wrote:
>> Using the newer pysqlite you've built instead of the distribution's broken
>> sqlite3 is also an option.
>    Would I then use the older syntax of 'from pysqlite2 import dbapi2 as
> sqlite3' rather than the newer 'import sqlite3?'

Yep.  You could also try both modules and pick the best one available at 
runtime.  Like this, yanked from SQLAlchemy's sqlite support:

     from pysqlite2 import dbapi2 as sqlite
except ImportError, e:
         # try the 2.5+ stdlib name.
         from sqlite3 import dbapi2 as sqlite
     except ImportError:
         raise e

# connection = sqlite.connect(...)
# ...

More information about the Portland mailing list