self.mycursor = self.mydb.cursor()
self.sql1 = "UPDATE counter SET count = %s WHERE id = %s"
self.val1 = (str(int('count' + 1)), '1')
self.mycursor.execute(self.sql1, self.val1)
self.mydb.commit()
在这部分代码中,我想增加查询值
最佳答案
如果您希望给定 id 的计数器加 1,您可以这样做:
self.sql1 = "UPDATE counter SET count = count + 1 WHERE id = %s"
self.val1 = (1)
self.mycursor.execute(self.sql1, self.val1)
关于python - 如何在 python 中增加查询值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59896641/