On Sat, Nov 15, 2014 at 1:14 PM, Tim Chase <python.l...@tim.thechases.com> wrote: > On 2014-11-15 12:48, Chris Angelico wrote: >> conn = establish_database_connection() >> try: >> do_stuff() >> finally: >> conn.rollback() > > this sounds suspiciously like you'd never actually commit. Do you > mean something like > > conn = establisth_database_connection() > try: > do_stuff(conn) > except: > conn.rollback() > raise
No; I prefer to have the commit be as close as possible to the code that needs it done. So in this toy example, the commit would be inside - maybe deep inside - do_stuff(). After committing, rolling back wouldn't hurt. ChrisA -- https://mail.python.org/mailman/listinfo/python-list