Cursor.execute 不适用于 Python
Cursor.execute does not work in Python
我正在使用 Python 中的 MySQLdb
包来更新我的数据库。我有一个简单的更新命令如下:
update_query = "update user_details set `address`='%s' where `id`='%s'"
cursor.execute(update_query, (address, id1))
print(cursor._last_executed)
这是执行的命令:
update user_details set `address`='35, Chikmagalur' where `id`='242069'
程序运行没有错误。但是,数据库没有得到更新。当我 运行 作为 PHPMyAdmin 上的 SQL 查询时,相同的命令有效。
知道可能是什么问题吗?
这是...的副本
sql 个事务需要显式或隐式提交。
要么显式发出提交命令
cursor._get_db().commit()
将连接设置为在打开连接时自动提交也是一个选项。
我正在使用 Python 中的 MySQLdb
包来更新我的数据库。我有一个简单的更新命令如下:
update_query = "update user_details set `address`='%s' where `id`='%s'"
cursor.execute(update_query, (address, id1))
print(cursor._last_executed)
这是执行的命令:
update user_details set `address`='35, Chikmagalur' where `id`='242069'
程序运行没有错误。但是,数据库没有得到更新。当我 运行 作为 PHPMyAdmin 上的 SQL 查询时,相同的命令有效。
知道可能是什么问题吗?
这是...的副本
sql 个事务需要显式或隐式提交。
要么显式发出提交命令 cursor._get_db().commit()
将连接设置为在打开连接时自动提交也是一个选项。