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

cursor dictionary and named_tuple parameter do not work anymore

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 1.1.3, 1.1.2
    • 1.1.4
    • DBAPI 2.0
    • None
    • 3.9

    Description

      Both named_tuple and dictionary are not working with the newer connector, both parameter will just a list of tuples on a fetchall.

      Minimal example:

      import mariadb
       
      conn_params = {"user": "root", "password": "xxx", "host": "localhost", "database": "myDB"}
      connection = mariadb.connect(**conn_params)
       
      # cursor = connection.cursor(named_tuple=True)
      cursor = connection.cursor(dictionary=True)
      cursor.execute("SELECT field FROM myTable")
      rows = cursor.fetchall()
      print(rows)
      # will print list of tuples without field names
      

      Attachments

        Activity

          georg Georg Richter added a comment -

          Confirmed - while fetchone() and fetchmany() work as expected, fetchall() uses iterator which calls the c function MrdbCursor_fetchone().

          georg Georg Richter added a comment - Confirmed - while fetchone() and fetchmany() work as expected, fetchall() uses iterator which calls the c function MrdbCursor_fetchone().
          georg Georg Richter added a comment -

          commit 275aaf3ee18027188990e09de8bddd38cbc38619 (HEAD -> 1.1, origin/1.1)
          Author: Georg Richter <georg@mariadb.com>
          Date: Wed Jul 6 22:57:58 2022 +0200

          Fix for CONPY-214:

          Replace cursor iterator by native python _iter_() method.

          Fix will be available with 1.1.4 release

          georg Georg Richter added a comment - commit 275aaf3ee18027188990e09de8bddd38cbc38619 (HEAD -> 1.1, origin/1.1) Author: Georg Richter <georg@mariadb.com> Date: Wed Jul 6 22:57:58 2022 +0200 Fix for CONPY-214 : Replace cursor iterator by native python _ iter _() method. Fix will be available with 1.1.4 release

          confirmed this bug. A workaround is to use something like:
          cur.fetchmany(cur.rowcount)

          ...which is not as pretty, but works.

          yengst thomas st.yeng added a comment - confirmed this bug. A workaround is to use something like: cur.fetchmany(cur.rowcount) ...which is not as pretty, but works.

          People

            georg Georg Richter
            fehrlich Franz Ehrlich
            Votes:
            0 Vote for this issue
            Watchers:
            3 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.