[ANN] pysqlite 2.0.alpha2

G

Gerhard Haering

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

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iD8DBQFCNPYcdIO4ozGCH14RAuiXAJ44TlX1eAdxk0vlHKMperOY4rLEywCfeX1P
ijREET8ProONmU3vE7x+KhQ=
=GxKq
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top