[mysql] Some non-transactional changed tables couldn't be rolled back

使用peewee的事务时,碰到一个郁闷的问题,事务似乎无效!

于是简化了下模型,写了简单的测试代码,发现问题,如题所示。

找到解答:

https://github.com/etianen/django-reversion/issues/362

https://dev.mysql.com/doc/refman/5.0/en/nontransactional-tables.html

原因就是数据库表的引擎需要设置为InnoDB才能支持事物,解决方法如下:

http://dev.mysql.com/doc/refman/5.6/en/converting-tables-to-innodb.html

即,将需要支持事物的表的引擎设置为InnoDB,sql如下:

alter table my_table engine=InnoDB;
原文地址:https://www.cnblogs.com/Tommy-Yu/p/4536732.html