我正在尝试用给定的ID在我的表中设置一个值。当我运行这段代码时,我第一次运行它时,在'cursor.execute(updateStr)‘上得到一个返回码1,但它执行起来没有问题,第二次运行它时返回0。谢谢你的关注。
updateStr = "UPDATE db.table SET OverrideVal = '{0}' WHERE table.OverrideID ={1};".format(overrideVal, overrideID)
returnCode = cursor.execute(updateStr)
if returnCode == 0:
cursor.execute("COMMIT")
else:
cursor.execute("ROLLBACK")
发布于 2018-06-30 03:00:47
我不认为execute命令会返回任何有意义的东西。Python's DB-API 2.0 states this about the execute method
未定义
返回值。
你有没有检查过你的更新是否真的在工作?(一定要提交它们)。
https://stackoverflow.com/questions/51107799
复制相似问题