【问题标题】:Unable to update Multiple cloums in a sql database table using pyodbc无法使用 pyodbc 更新 sql 数据库表中的多个列
【发布时间】:2014-08-11 06:00:39
【问题描述】:

我目前正在做一个学校项目。我需要更新表中的 GPS 坐标。我正在使用 Raspberry pi board、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)

但我需要一次更新这两个参数。任何人都可以帮助我吗?感谢您阅读本文。。

【问题讨论】:

    标签: python sql raspberry-pi pyodbc


    【解决方案1】:

    SQL UPDATE syntax

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-22
      • 1970-01-01
      • 2021-06-12
      相关资源
      最近更新 更多