logo       

Re: executescript does not end the transaction: msg#00055

python.db.pysqlite.user

Subject: Re: executescript does not end the transaction

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

jt wrote:
> On 5/10/06, Ed Pasma <ed.pasma-39ZsbGIQGT7z+pZb47iToQ@xxxxxxxxxxxxxxxx> wrote:
>>Hello, perhaps I'm misunderstanding. But may be you can connect to
>>the database with isolation_level=None. So you can use begin and
>>commit. Or does executescript commit regardless of that?
>
> On error executescript do not commit nor rollback. I think it is
> related to the last line of section 5 in usage guide:
>
> "Instead, catch the IntegrityError and call the rollback method of the
> connection yourself."
>
> Am I right with this?
> When I catch the exception I now call con.execute("ROLLBACK;") and it
> seems to work as I intend, but a con.rollback() won't rollback! What
> is the difference between the rollback method and executing a ROLLBACK
> statement?

The rollback method of the connection only actually does anything if it
"thinks" that you're within a transaction. pysqlite is able to always know,
because you are not supposed to use any transaction-oriented commands
(BEGIN, COMMIT, ROLLBACK) in execute* methods if you are not in autocommit
mode (i. e. isolation_level=None).

- -- Gerhard
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFEY7qsdIO4ozGCH14RAolYAJ9o0J+0sqsYtVyC3hHbV5H5ruVnEwCeKfZY
+KJr1huL91saE2ikOOZoFPY=
=fvPC
-----END PGP SIGNATURE-----


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise