pymysql在重复密钥更新

时间:2019-06-27 09:45:06

标签: python mysql sql pymysql

我使用MySQL 8.0,python 3.7.3,pymysql和Windows 10。

执行以下查询时,我不断收到此错误:

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)

错误是:

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")

我找不到问题。怎么了?

0 个答案:

没有答案
相关问题