Simon Slavin wrote: > On 7 Apr 2017, at 6:58am, Clemens Ladisch <clem...@ladisch.de> wrote: >> David Raymond: >>> https://docs.python.org/2/reference/datamodel.html#with-statement-context-managers >>> >>> For the sqlite3 module connection object: on a bad exit from an >>> exception it will do a rollback, on a clean exit it will do a commit, >>> and run .close() either way. >> >> It does not run .close(). > > Doesn’t seem to run .close() on __exit_ or __del_. But in another > thread DRH has posted that failing to close a connection won’t do any > serious harm. Still troubles me as a programmer, though, to see an > 'open' without a 'close'.
There is no separate transaction object, so the only way to handle transactions with a context manager is the connection object itself. Apparently, handling transactions was thought to be more important than cleaning up the connection itself. Anyway, automatically closing the connection is still possible: with contextlib.closing(sqlite3.connect('...')): ... Regards, Clemens _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users