我有一个表要更新,column1是主键

| chute | five |
|-------|------|
| Fa01  | null |
|-------|------|
| Fa02  | null |
|-------|------|
| Fa03  | null |
|-------|------|

我想用基于列1中键的数据列表更新列2。
sort_list = [('10.0','Fa01'),('23.0','Fa02'),('35.0','Fa03'),('9.0','Fa04')]

query = "UPDATE ship_divert SET five = %s, WHERE chute = %s"
cursor.executemany(query,sort_list)

但是,当我运行包含此查询的函数时,会出现以下错误
'...for the right syntax to use near 'WHERE chute = 'Fa01''

我在mysql控制台上测试了不带变量的查询,它可以工作
UPDATE ship_divert
SET five='28.0'
WHERE chute = 'Fa02'

我的脚本语法哪里不正确?

最佳答案

您需要删除sql中的,

query = "UPDATE ship_divert SET five = %s, WHERE chute = %s"
                                         ^

10-06 07:05