import pysqlite2 or import sqlite3?

Nick Craig-Wood nick at craig-wood.com
Sun Nov 25 16:30:04 EST 2007


MonkeeSage <MonkeeSage at gmail.com> wrote:
>  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

I've been using

     import sqlite3 as sqlite

here

sqlite3 and sqlite3.dbapi2 seem to be the same thing

    Python 2.5.1 (r251:54863, Aug 17 2007, 00:51:07)
    [GCC 4.1.3 20070812 (prerelease) (Debian 4.1.2-15)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from sqlite3 import dbapi2
    >>> import sqlite3
    >>> set(dir(sqlite3)) ^ set(dir(dbapi2))
    set(['__path__', 'dbapi2'])
    >>>

-- 
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick



More information about the Python-list mailing list