How To On Duplicate Key Update
I have this query that is executed in my Python script but when its inserting into the database and finds a duplicate of my unique column it causes it to error and stops. I know I
Solution 1:
When I understand you correctly, what you are looking for is this:
cur.execute(""" INSERT INTO logs (1, 2, 3) VALUES (%s, %s, %s) ON DUPLICATE KEY UPDATE 1=%s, 3=%s """, (line[0], line[1], line[2], line[0], line[2]))
Check also Insert on duplicate.
Post a Comment for "How To On Duplicate Key Update"