try pattern for database connection with the close method

Mario Figueiredo marfig at gmail.com
Sun Feb 22 18:25:26 EST 2015


On Sun, 22 Feb 2015 19:07:03 +0000, Mark Lawrence
<breamoreboy at yahoo.co.uk> wrote:

>
>Looks like you're correct.  Knock me down with a feather, Clevor Trevor.

It took me by surprise when I first encountered it too. The rationale
apparently is that the context manager is strictly a transactional
feature, allowing for multiple context managers within the same
connection to properly perform commits and rollbacks on multiple
transactions.



More information about the Python-list mailing list