无法使用pyodbc更新SQL数据库表中的多个列
我现在在做一个学校的项目。我需要在表格中更新GPS坐标。我使用的是树莓派板子、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 个回答
3
请查看这个SQL UPDATE 语法:
cursor.execute("update Gps_table set longitude=?,latitude=? where gps_id=1", s1, s2)