I use MySQL 8.0, python 3.7.3, pymysql and Windows 10.
I keep getting this error when executing the following query:
sql = "INSERT INTO personnel_duties(scenario_id, id, function, validfrom, validto, duty_type) VALUES (%s, %s, %s, %s, %s, %s) \
ON DUPLICATE KEY UPDATE \
function = %s, \
validto = %s"
val_list = [0, 2246, 'X', datetime.datetime(2019, 6, 27, 0, 0), datetime.datetime(2035, 1, 1, 0, 0), '555', 'X', datetime.datetime(2035, 1, 1, 0, 0)]
self.cursor.execute(sql, val_list)
error is:
pymysql.err.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'function, validfrom, validto, duty_type) VALUES (0, 2246, 'X', '2019-06-27 00:00:0' at line 1")
I couldn't find the problem. What is wrong?