以下是我尝试执行的代码
db.execute('''UPDATE WARDWINS \
SET map = ?,
SET team1wards = ?,
SET team2wards = ?,
SET mostwards = ?,
SET winningteam = ?,
SET mostwardswin = ?
where matchID = ?''', (dic['mapID'][0], dic['team1wards'], dic['team2wards'], dic['mostwards'], dic['winningteam'], dic['wardswins'], match))
我想要实现的是让一个执行命令同时更新所有上述行,但由于某种原因,我似乎无法弄清楚如何做到这一点。我收到以下错误消息:
>>> dic['mostwards'], dic['winningteam'], dic['wardswins'], match))
sqlite3.OperationalError: near "SET": syntax error
答案 0 :(得分:-1)
所以,事实证明,答案几乎是正确的。 (不是一直吗?) sqlite3.execute命令只需要一个SET,其他的都是冗余的,并且会产生语法错误。正确的做法如下:
db.execute('''UPDATE WARDWINS \
SET map = ?,
team1wards = ?,
team2wards = ?,
mostwards = ?,
winningteam = ?,
mostwardswin = ?
where matchID = ?''', (dic['mapID'][0], dic['team1wards'], dic['team2wards'], dic['mostwards'], dic['winningteam'], dic['wardswins'], match))