How to start a transaction?

M.-A. Lemburg mal at
Tue Jan 20 14:25:18 CET 2009

On 2009-01-20 12:23, Hussein B wrote:
> Hey,
> I know the basics of interacting with databases in Python.
> How to start a transaction in case I want to group a couple of insert
> and update statements into a single operation?

If you use a Python DB-API compatible database module, then
transactions are enabled per default after you connect to the
database. connection.commit() and .rollback() then complete a
transaction and implicitly start a new one.

Marc-Andre Lemburg

Professional Python Services directly from the Source  (#1, Jan 20 2009)
>>> Python/Zope Consulting and Support ...
>>> mxODBC.Zope.Database.Adapter ...   
>>> mxODBC, mxDateTime, mxTextTools ...

::: Try our new mxODBC.Connect Python Database Interface for free ! :::: Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611

More information about the Python-list mailing list