[DB-SIG] Use of context managers with DB API 2

Christoph Zwerschke cito at online.de
Sun Nov 4 23:24:53 CET 2012


Am 04.11.2012 19:32, schrieb Michael Bayer:
 > IMHO the DBAPI is a low level API that should do just one thing,
 > allow rudimental functionality to a relational database with as much
 > consistency as possible.

Essentially agreed, but I think it's excusable for SQLite as a 
light-weight database to make an exception here so that it can be used 
easily and directly from the standard lib without the need to install 
any additional higher level wrapper.

To wrap everything up, as a result of our discussion, I will do the 
following in the next version of PyGreSQL:

* make connections context managers for transactions
   (may not be the optimal solution, but it's already established)
* make cursors self-closing context managers (evident)
* not implement shortcut functions (see above)

Is everybody happy with that?

-- Christoph


More information about the DB-SIG mailing list