Re: Transaction-handling issues

Martin Jenkins <mj-Vfh7fEhEWOlaa/[email protected]>
Newsgroups gmane.comp.python.db.pysqlite.user
Organization XQP Ltd
Message-ID <[email protected]>
Ed Pasma wrote:
> Dear all,
> When automatic transactions are enabled, as per the default, PySQLite  
> automatically issues a begin statement before it first executes an  
> update or other dml-statement. In this mode, begin should never be  
> added programmaticaly as an SQL-statement. Doing so will raise an  
> error as soon as PySQLite does the automatic begin. The error mesage  
> in this case is: "SQL Logic error or missing database".

If you're doing something like this:

 >>> import sqlite3
 >>> C=sqlite3.Connection(":memory:")
 >>> C.execute("begin")
 >>> C.execute("create table t(a);")
 >>> C.executemany("insert into t values(?); end;", (1,2,3))
Traceback (most recent call last):
   File "<interactive input>", line 1, in <module>
OperationalError: SQL logic error or missing database
 >>>

then it's a bug in the wrapper. There's a sqlite3_reset() missing from 
the executemany method.

Fixing that omission gives the correct (as per the auto-BEGIN semantics) 
error:

Traceback (most recent call last):
   File "<interactive input>", line 1, in <module>
OperationalError: cannot start a transaction within a transaction

HTH

Martin
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.