Skip to content

Error using "ON DUPLICATE KEY UPDATE" with "executemany()" #106

Open

Description

@AlexLanes

I'm getting the error below using ON DUPLICATE KEY UPDATE with executemany().
The same doesn't happen using execute() with 1 param at a time.

--- SQL ---
INSERT INTO usuarios
(active, email, age, name)
VALUES (%s, %s, %s, %s)
ON DUPLICATE KEY UPDATE
name = %s

--- PARAMS ---
(True, 'joao@email.com', 29, 'JoaoValues', 'NAME_UPDATE')
(True, 'alex@email.com', 29, 'AlexValues', 'NAME_UPDATE')

Error

  File "c:\Projetos\Python\simple_sql_builder\.venv\Lib\site-packages\mysql\connector\cursor.py", line 519, in executemany
    stmt = self._batch_insert(operation, seq_params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Projetos\Python\simple_sql_builder\.venv\Lib\site-packages\mysql\connector\cursor.py", line 465, in _batch_insert
    raise ProgrammingError(
mysql.connector.errors.ProgrammingError: Not all parameters were used in the SQL statement

Activity

  1. Ch3M4x commented on Oct 8, 2026

    @Ch3M4x
    Member

    Hello @AlexLanes,

    Thank you for reporting this and sharing the example. We were able to reproduce the issue and will work on a fix.

    We would also appreciate it if you could file a report in our MySQL bugs page which will be used to keep track of this issue.

    Regards,
    MySQL Team

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions