使用innondb引擎从mysql数据库插入python脚本时出现的问题

2024-09-29 23:15:32 发布

您现在位置:Python中文网/ 问答频道 /正文

我面临一个问题,我试图用InnonDB引擎将python脚本中的数据添加到mysql数据库中,它与mysql数据库的myisam引擎配合得很好。但是myisam引擎的问题是它不支持外键,所以我必须在数据库中插入/删除记录的每个地方添加额外的代码。在

有人知道为什么InnonDB不能使用python脚本和可能的解决方案吗??在


Tags: 数据代码引擎脚本数据库地方记录mysql
2条回答

Python DB API默认情况下禁用自动提交

从谷歌粘贴(第一页,第二个结果)

MySQL :: MySQL 5.0 Reference Manual :: 13.2.8 The InnoDB ... By default, MySQL starts the session for each new connection with autocommit ...dev.mysql.com/.../innodb-transaction-model.html

但是

显然Python以非自动提交模式启动MySQL,请参见:
http://www.kitebird.com/articles/pydbapi.html

文章内容:

The connection object commit() method commits any outstanding changes in the current transaction to make them permanent in the database. In DB-API, connections begin with autocommit mode disabled, so you must call commit() before disconnecting or changes may be lost.

笨蛋,不知道该怎么克服,我不想让你猜错了。 我建议提出一个新问题,题目是:

如何在MySQL python DB-API中启用自动提交模式?在

祝你好运。在

InnoDB是事务性的。你需要打电话连接.提交()插入/删除/更新后。在

编辑:你可以打电话连接.自动提交(True)打开自动提交。在

相关问题 更多 >

    热门问题