I need to update the row if the record already exists or create a new one if it is not ready. I am disappointed in the DUPLICATE KEY, will do this with MYSQLdb, however I am having problems with its operation. My code is below
cursor = database.cursor()
cursor.execute("INSERT INTO userfan (user_id, number, round VALUES (%s, %s, %s) ON DUPLICATE KEY UPDATE user_id =%s, number=%s, round=%s", (user_id, number, round))
database.commit()
The primary key is user_id
source
share