[Zope-DB] working with zope rdbms transaction mgmt
M.-A. Lemburg
mal at egenix.com
Fri Jul 2 13:01:49 EDT 2004
Jim Abramson wrote:
> Hello all,
>
> As has been mentioned many times on that list, calling explicit 'commit' on the db connection you
> are using during a Zope request is a no-no...
>
> My question is, if i grab a reference to the cursor from some db connection inside a python
> script, and do a bunch of statements directly on this cursor, and something goes wrong on the nth
> statement (i.e. uncaught Exception), should I expect all of the statements performed using that
> cursor up to that point will be automatically rolled back?
Yes.
> If yes, next question is, if I trap an exception that's raised during the nth statement, and
> proceed (using the same cursor) to the (n+1)th statement, and the REQUEST wraps up cleanly,
> should I expect all of the successful statements will be automatically committed?
Yes.
That ways easy :-)
Database transactions are handled on the connection, not the cursors,
so unless you connection dies in the middle of processing a request,
anything you do on the connection will get committed if Zope finds
that processing was successful, that is in particular, no unhandled
exception was raised.
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, Jul 02 2004)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::
More information about the Zope-DB
mailing list