From the docs: http://docs.python.org/2/library/sqlite3.html#using-the-connection-as-a-context-manager
Connection objects can be used as context managers that automatically commit or rollback transactions. In the event of an exception, the transaction is rolled back; otherwise, the transaction is committed:
So, the context manager doesn’t release the connection, instead, it ensures that any transactions occurring on the connection are rolled back if any exception occurs, or committed otherwise… Useful for DELETE
, UPDATE
and INSERT
queries for instance.
3
solved using sqlite3 in python with “WITH” keyword