-
Type:
New Feature
-
Status: Closed (View Workflow)
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 0.9.55
-
Fix Version/s: 0.9.56
-
Component/s: Generic
-
Labels:None
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.