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

MariaDB 5.5 or MySQL: executemany() doesn't work with NULL values

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 0.9.59
    • 1.0.0
    • DBAPI 2.0
    • None

    Description

      When inserting NULL values to a server which doesn't support BULK statements NULL values are not inserted correctly.

      Example:

      import mariadb
       
      conn=mariadb.connect(user="georg", database="test")
      cursor=conn.cursor()
      cursor.execute("CREATE TEMPORARY TABLE ind1 (a int, b int default 2,c int)")
      vals = [(1,4,3),(None, 2, 3)]
      cursor.executemany("INSERT INTO ind1 VALUES (?,?,?)", vals)
      cursor.execute("SELECT a, b, c FROM ind1")
      row= cursor.fetchall()
      print(row)
      

      Attachments

        Activity

          MichaelCurrie Michael Currie added a comment - - edited

          I've tested this code with Python 3.10 and mariadb connector 1.1.6 and it works fine, it returns

          [(1, 4, 3), (None, 2, 3)]
          

          , as expected.

          However, if you change to vals = [(1,4,3),(None, 2, None)] it fails with:

          SystemError: <method '_execute_bulk' of 'mariadb.cursor' objects> returned NULL without setting an exception

          (see issue: @PythonCONPY-254)

          MichaelCurrie Michael Currie added a comment - - edited I've tested this code with Python 3.10 and mariadb connector 1.1.6 and it works fine, it returns [( 1 , 4 , 3 ), ( None , 2 , 3 )] , as expected. However, if you change to vals = [(1,4,3),(None, 2, None)] it fails with: SystemError: <method '_execute_bulk' of 'mariadb.cursor' objects> returned NULL without setting an exception (see issue: @PythonCONPY-254)

          People

            georg Georg Richter
            georg Georg Richter
            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.