【发布时间】:2019-03-17 10:24:56
【问题描述】:
我试图在 python 中运行 sql 查询来更新数量,但我得到了错误。
cur.execute(
"UPDATE Products SET Price =? , Quantity =? , RackLocation =? WHERE ID =?",
[self.new_price.get(), self.new_quantity.get(), self.new_racklocation.get(), self.id]
)
我收到此错误:
[int(self.new_quantity.get()) , int(self.id)])
pyodbc.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC SQL Server Driver]
[SQL Server]Incorrect syntax near '='. (102) (SQLExecDirectW); [42000]
[Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not be
prepared. (8180)")
【问题讨论】:
-
如果您只是将它们打印到控制台,您的 get 方法会返回什么?
-
Edit你的问题并解释“减列”的含义?
-
您好,谢谢您的回复,其实我的查询是错误的。我将我的查询更改为它有效。
-
cur.execute("UPDATE Products SET Quantity = Quantity - 1 WHERE ID=?", [self.id])