Skip to content

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

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

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