Open
Description
Taken from @chriskuehl's comment on #103:
This is fine, but eventually we should take the opportunity to fix this API. Currently it's really hard to write correct code which closes connections as you'd expect; a better API would be something like this:
@contextlib.contextmanager def get_connection(...): with contextlib.closing(pymysql.connect(...)) as conn: yield conn
Then usage is like this:
with get_connection() as conn: with conn as cursor: cursor.execute('...')
Currently we never call close on the connections we open.
Metadata
Assignees
Labels
No labels