That's just my own personal paranoia wanting to make sure the cursor always gets closed, even on an exception. As I don't think the normal context manager on a cursor closes it when it exits.
In the real world it's probably overkill as a) The destructors probably take care of that b) It's the connection you're more worried about and not the cursor c) SQLite is designed to handle crashes, etc. -----Original Message----- From: sqlite-users <sqlite-users-boun...@mailinglists.sqlite.org> On Behalf Of Peng Yu Sent: Thursday, January 30, 2020 11:02 AM To: SQLite mailing list <sqlite-users@mailinglists.sqlite.org> Subject: Re: [sqlite] Does .commit() ensure the .execute()'s and .executemany()'s called before are run atomically? Thanks. What is the purpose of contextlib. If I just use `cur = conn.cursor()`, what problems it will cause? > with contextlib.closing(conn.cursor()) as cur: -- Regards, Peng _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users