[DB-SIG] autocommit support in pep-249

M.-A. Lemburg mal at egenix.com
Wed Sep 14 12:45:49 CEST 2011

Chris Clark wrote:
> Hi All,
> I was discussing with someone today autocommit support and found an area
> of pep-249 where I think we could improve the wording (and the spec):
> http://www.python.org/dev/peps/pep-0249/
> .....
>        .commit()
>                     Commit any pending transaction to the database. Note
> that
>            if the database supports an auto-commit feature, this must
>            be initially off. An interface method may be provided to
>            turn it back on.
> .....
> It is the last sentence that I'm looking at:
>> An interface method may be provided to turn it back on.
> Comments:
>    * The "may" clearly marks this as an optional interface (and I'm
>      happy about that).
>    * It would be helpful to make clear what the interface method would
>      be so module authors can implement this consistently
>    * if autocommit can be turned on in a connection, there should have
>      a way to turn it off again
> ...
> Comments?

mxODBC and mxODBC Connect will support a writable connection
attribute connection.autocommit to turn the feature on/off.
This works by assigning a boolean to the attribute. The
attribute also allows for an easy way to check whether autocommit
is active or not.

They both already support doing this via the (non-standard) DB-API
extension connection.setconnectoption() method.

>From an API perspective, using an attribute is the right
and user-friendly approach. My only gripe with this is the fact,
that querying or setting the attribute can cause exceptions,
which you'd normally only expect from function/method calls.

Other than that I'm +1 on adding the attribute as standard
DB-API 2.0 extension.

Marc-Andre Lemburg

Professional Python Services directly from the Source  (#1, Sep 14 2011)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
2011-10-04: PyCon DE 2011, Leipzig, Germany                20 days to go

::: Try our new mxODBC.Connect Python Database Interface for free ! ::::

   eGenix.com 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 DB-SIG mailing list