[ANN] pysqlite 2.0.alpha2

Gerhard Haering gh at ghaering.de
Sun Mar 13 21:25:32 EST 2005


pysqlite 2.0.alpha2
===================

The last release was back in Nov. 2004, but pysqlite 2 development is going on
faster now. So it's time for another alpha release to collect feedback.

Please report any bugs you find on the pysqlite mailing list, or even better on
the trac tracking system at http://initd.org/tracker/pysqlite

Downloads at Sourceforge:
http://sourceforge.net/project/showfiles.php?group_id=54058&package_id=134545

The project itself at http://pysqlite.org/ 



Changes since pysqlite 2.0.alpha1
=================================

Namespaces change:
    - the DB-API module is now called pysqlite2.dbapi2 instead of sqlite, you
      typically import it using "from pysqlite2 import dbapi2 as sqlite"

DB-API compliance:
    - implemented all module-level constants and functions that are required
      for DB-API compliance

Type system:
    << Type conversion SQLite => Python >>

    ** SQLite types mode (default **
    - nothing happens behind your back. if you SELECT, you get back the types
      SQLite reports. So, you will only get strings, ints, floats, and BLOBs
      (BLOBs as Python buffer objects)

    ** pysqlite types mode (have to activate explicitly) **
    - the returned type depends on the decleared column for the SELECTed data.
      To use it successfully, you must register converters for the column types
      (see below). You can also set the declared column types explicitly using
      the coltypes property of cursors (see below)
    - new method register_converter(coltypes, converter) for connection objects:
        * con.register_converter("int": int)
        * con.register_converter("unicode": unicode)
        * con.register_converter("boolean": bool)
        * con.register_converter("foo": lambda x: "<%s>" % x)
        * class Bar: ...
          con.register_converter("bar": Bar)
    - new property coltypes of cursor objects:
        cur.coltypes = {"col1": int}
        cur.execute("select foo as col1 from bar")

    << Type conversion Python => SQLite >>
    - Like in PEP 246 (Object Adaptation)
    - the default protocol does nothing, except handle Unicode strings
    - the protocol's __adapt__ returns the SQLite value directly at the moment
      (this will perhaps change in the next release)
    - example protocol:
        class P(dbapi2.SQLitePrepareProtocol):
            def __adapt__(self, obj):
                if isinstance(obj, Point):
                    return "(%s/%s)" % (obj.x, obj.y)
                else:
                    return dbapi2.SQLitePrepareProtocol.__adapt__(self, obj)
        con = sqlite.connect(":memory:", more_types=True, prepareProtocol=P())

Connect call:
    - Syntax is now:
        con = sqlite.connect(database, timeout, protocol, more_types)

        * timeout: timeout parameter in seconds, until error raised if
          concurrent access. in alpha1, it just failed immediately
        * protocol: see Type system
        * more_types: set to true if you want to use the pysqlite types mode
          instead of the default SQLite one

Misc.:
    - pysqlite.dbapi2 now has constants version and version_info
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: Digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20050314/fcbbfc2d/attachment.sig>


More information about the Python-list mailing list