This is a read-only copy of the MariaDB Knowledgebase generated on 2024-11-16. For the latest, interactive version please visit https://mariadb.com/kb/.

How to avoid duplicate inserts with python library

The import from a csv with python and with using the import mariadb lib works with that code example very well:

cursor.execute("INSERT INTO connect_table (client, \ server,service) \ VALUES (?, ?, ?)", row)

Now I try to avoid duplicates with that method but it does not work.

cursor.execute("INSERT INTO connect_table (client, \ server,service) \ VALUES (?, ?, ?)", (row) \ "ON DUPLICATE KEY UPDATE client=" row[0], \ "server =" row[1], "service =" row[2])

How to prevent duplicates during import from csv files and with python?

Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.