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

using cursor.scroll(-1) return tuples instead of dict at next fetch

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 1.1.10
    • 1.1.11
    • DBAPI 2.0
    • None
    • Windows 11
    • 3.12.1

    Description

      *Running this script returns tuple instead of dict after cursor.scroll(-1) in Windows 11.
      This works okay (returns 2 dict's) on Ubuntu 22.04 with mariadb 1.1.6 and 1.1.10 *

      import mariadb
      dbconfig =

      {'user': 'xxxx', 'password': 'xxxx', 'database': 'xxxx', "host": "localhost", "port": 3306}

      cnx = mariadb.connect(**dbconfig)
      cnx.autocommit = True
      csr = cnx.cursor(buffered=True, dictionary=True)

      csr.execute("select ID,Text from test limit 2")

      print("test 1")
      i = 0
      for row in csr:
      print(row, type(row))
      csr.scroll(-1)
      i += 1
      if i > 1: # this test is used to prevent endless loop
      break

      cnx.close()

      OUTPUT

      test 1

      {'ID': 1, 'Text': 'aa'}

      <class 'dict'>
      (1, 'aa') <class 'tuple'>

      TABLE CONTENT

      ID Text
      1 aa
      2 bb
      3 cc
      4 dd
      5 ee

      Attachments

        Activity

          georg Georg Richter added a comment -

          Thanks for your bug report - looks like the result type will be overwritten

          >>> cursor._resulttype
          2
          >>> cursor.fetchone()
          {'1': 1}
          >>> cursor._resulttype
          2
          >>> cursor.scroll(-1)
          >>> cursor._resulttype
          0
          

          georg Georg Richter added a comment - Thanks for your bug report - looks like the result type will be overwritten >>> cursor._resulttype 2 >>> cursor.fetchone() { '1' : 1 } >>> cursor._resulttype 2 >>> cursor.scroll(- 1 ) >>> cursor._resulttype 0
          vincent.lemoine@iwa-consult.nl V H Lemoine added a comment -

          When is 1.1.11 available?

          vincent.lemoine@iwa-consult.nl V H Lemoine added a comment - When is 1.1.11 available?

          People

            georg Georg Richter
            vincent.lemoine@iwa-consult.nl V H Lemoine
            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.