【发布时间】:2017-03-25 10:04:49
【问题描述】:
我有一个要更新的表,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'
我的脚本中哪里的语法不正确?
【问题讨论】: