I wonder if I can use the with context manager with Connection object and write code like this:
with
Connection
with MySQLdb.connect(...) as conn: do_something()
Will the conn object close automatically after a block like the file object?
conn
file
Thanks.
MySQLdb does not support the context manager protocol. Roll your own or use oursql instead.