[pysqlite] pysqlite2.dbapi2.OperationalError: cannot commit transaction - SQL statements in progress

Gerhard Haering gh at ghaering.de
Thu May 19 05:14:05 EDT 2005


On Wed, May 18, 2005 at 09:41:39PM +0200, F. GEIGER wrote:
> I've troubles to let my app take off using pysqlite.
> 
> What I wonder most for now is that "pysqlite2.dbapi2.OperationalError:
> cannot commit transaction - SQL statements in progress" when I do this:
> 

Urgh! I would have preferred simplified demo code. But after a little
thinking, I guessed right.

> [...]

pysqlite 2 currently has problems doing .commit() .rollback() on the
connection object after a cur.execute("select ...") in a few cases.

I know why and I will fix it in 2.0.2 (originally only MacOS X fixes
planned) or if it takes longer to test, in 2.0.3.

Current workarounds:

- don't commit/rollback after SELECT. It doesn't make much sense anyway.
  .commit()/.rollback() after your DML statements instead
  (INSERT/UPDATE/DELETE).

- Use fetchall()[0] for fetching single rows instead of fetchone() for
  queries like your SELECT COUNT.

-- Gerhard
-- 
Gerhard Häring - gh at ghaering.de - Python, web & database development
-------------- 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/20050519/f6b0e98c/attachment.sig>


More information about the Python-list mailing list