我使用下面的代码来更新我的表的记录,但它不起作用,也不更新我的表
conn = mysql.connector.connect(host='localhost',
database='rps',
user='root',
password='')
cur = conn.cursor()
cur.execute("""UPDATE players SET score=%s WHERE chat_id =%s""", (int(self.p1.score), str(self.p1.chat__id)))
cur.execute("""UPDATE players SET score=%s WHERE chat_id =%s""", (int(self.p2.score), str(self.p2.chat__id)))
conn.commit()
cur.close()
conn.close()
这是完全正确的,但我不知道如何解决这个问题 你们能帮我解决吗伙计们? 谢谢
您可以在查询执行时设置try/catch:
如果你没有捕捉到任何异常,你应该检查你的程序逻辑。在
相关问题 更多 >
编程相关推荐