我使用 Python 2.7 和 pypyodbc 来运行 SQL 查询,但是每当我使用 python 运行更新查询时,
cursor.execute("UPDATE tbl_User SET gender = ? WHERE id = 1", ['male'])
我得到错误:
TypeError: string or integer address expected instead of instance instance
如果我直接在 SQL Server 上运行相同的查询,它会起作用。
最佳答案
问题是我没有在查询的末尾加上分号。解决方案是:
cursor.execute("UPDATE tbl_User SET gender = ? WHERE id = 1;", ['male'])
关于Python SQL 更新查询 : string or integer address expected instead of instance instance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37615316/