Python、sqlite3和更新几行
下面是我试图执行的代码Python、sqlite3和更新几行,python,sqlite,set,Python,Sqlite,Set,下面是我试图执行的代码 db.execute('''UPDATE WARDWINS \ SET map = ?, SET team1wards = ?, SET team2wards = ?, SET mostwards = ?, SET winningteam = ?, SET mostwardswin = ? where matchID = ?''', (dic['mapID'][0], dic['team1wards'],
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))
我想要实现的是让一个execute命令同时更新上面的所有行,但由于某种原因,我似乎无法理解如何做到这一点。我收到以下错误消息:
>>> dic['mostwards'], dic['winningteam'], dic['wardswins'], match))
sqlite3.OperationalError: near "SET": syntax error
因此,事实证明,答案几乎是正确的。(不总是这样吗?) sqlite3.execute命令只需要一个集合,其他集合是多余的,因此产生了语法错误。正确的做法如下:
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))
因此,事实证明,答案几乎是正确的。(不总是这样吗?) sqlite3.execute命令只需要一个集合,其他集合是多余的,因此产生了语法错误。正确的做法如下:
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))