Uploaded image for project: 'MariaDB Connector/Python'
  1. MariaDB Connector/Python
  2. CONPY-46

Cursors cannot act as a context manager

    XMLWordPrintable

    Details

    • 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

      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.

        Attachments

          Activity

            People

            Assignee:
            georg Georg Richter
            Reporter:
            karll Karl Levik
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: