[ANN] pysqlite 2.5.2

Gerhard Häring gh at ghaering.de
Tue Mar 3 11:05:16 CET 2009

pysqlite 2.5.2 released

Release focus: minor bugfixes, minor new features.

pysqlite is a DB-API 2.0-compliant database interface for SQLite.

SQLite is a in-process library that implements a self-contained,
serverless, zero-configuration, transactional SQL database

Go to http://pysqlite.org/ for downloads, online documentation and
for reporting bugs.


- Like on Connection.rollback(), Connection.commit() now resets
  all statements associated to the connection, so that the
  commit() should always succeed (unless other connections create

- pysqlite used to deliver bogus results on cursors that still
  have unfetched data when a rollback() was done on the
  connection. A commit() or rollback() now puts the cursor into a
  "reset" state. If you try to fetch data after commit() or
  rollback() you will now get an InterfaceError exception instead
  of bogus data.

- For better DB-API compliance, operations on closed cursors now
  raise exceptions.

- Add amalgamation directory to include path when building
  statically against amalgamation files.

  Otherwise, building against the amalgamation only worked if you
  already had the SQLite3 header files in the search path. Like
  on my development system ;-)

- Made sure HAVE_LOAD_EXTENSION is not defined twice. Also made
  sure that it's OFF if the OMIT macro is defined.

- Fixed check if non-UTF8 strings are acceptable input. The check
  was wrong for OptimizedUnicode. Also added the missing tests
  for this feature.

- Wrap routine sqlite3_load_extension as method load_extension of
  the Connection object.


The fact that commit() and rollback() now reset all associated cursors
the behaviour of pysqlite. Some code that previously worked will now raise
InterfaceError exceptions. OTOH the code did not really *work*, because it
produced wrong results.

In previous pysqlite versions:

>>> from pysqlite2 import dbapi2 as sqlite3
>>> con = sqlite3.connect(":memory:")
>>> con.executescript("create table t(c); insert into t(c) values (1);
insert into t(c) values (2); insert into t(c) values (3);")
<pysqlite2.dbapi2.Cursor object at 0xb7e79d40>
>>> cur = con.cursor()
>>> cur.execute("insert into t values (4)")
<pysqlite2.dbapi2.Cursor object at 0xb7e79770>
>>> cur.execute("select * from t")
<pysqlite2.dbapi2.Cursor object at 0xb7e79770>
>>> con.rollback ()
>>> print cur.fetchall ()
[(1,), (1,), (2,), (3,)]

  ^     ^

!! Notice the duplicate rows with values (1,) !! This code produced
wrong results.

With this release, the last cur.fetchall() will raise an exception:

>>> print cur.fetchall ()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  pysqlite2.dbapi2.InterfaceError: Cursor needed to be reset because of
commit/rollback and can no longer be fetched from.

More information about the Python-announce-list mailing list