我尝试在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)")
答案 0 :(得分:0)
我做错了。查询应如下所示
cur.execute(“更新产品设置数量=数量-1 WHERE ID =?”, [self.id])