Details
-
New Feature
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
0.9.55
-
None
Description
I noticed this feature request for the MySQL Python connector, and thought it might be useful for the MariaDB Python connector as well:
https://bugs.mysql.com/bug.php?id=89113
Most Python DB-API 2.0 compliant drivers can create cursors as a context manager, like so:
with conn.cursor() as cur:
cur.execute(query)
result = cur.fetchone() print(result)
The cursor is created and assigned the identifier `cur`, and when exiting the scope, the cursor is automatically closed.