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

Cursors cannot act as a context manager

    XMLWordPrintable

Details

    • New Feature
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 0.9.55
    • 0.9.56
    • Generic
    • 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

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

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.