无法使用pyodbc更新sql数据库表中的多个列

时间:2014-08-11 06:00:40

标签: python sql raspberry-pi pyodbc

我目前正在开展一个学校项目。我需要更新表格中的GPS坐标。我正在使用Raspberry pi板,pyodbc,freeTds和sql数据库。我不能连续更新多个项目..

cursor.execute("update Gps_table set longitude=(?) latitude=(?) where gps_id=1", s1, s2)

上面的代码不起作用..但是我已经弄明白了,当我一次只传递一个变量时它就可以工作了。这意味着以下代码正在运作..

cursor.execute("update Gps_table set longitude=(?) where gps_id=1", s1)
cursor.execute("update Gps_table set latitude=(?) where gps_id=1", s2)

但我需要一次更新这两个参数。任何人都可以帮助我。感谢您阅读此内容..

1 个答案:

答案 0 :(得分:3)

请参阅SQL UPDATE syntax

cursor.execute("update Gps_table set longitude=?,latitude=? where gps_id=1", s1, s2)