几个月来,我一直在广泛使用 peewee 和 postgresql。突然间,这开始发生了。如果我运行任何查询命令并收到错误,则所有后续命令开始返回 peewee.InternalError: current transaction is aborted, commands ignored until end of transaction block
。
我认为这种行为是在我将 peewee 从 3.5.2 升级到 3.7.2 时开始的,但后来我降级了,这种行为仍在继续。这绝对不会一直发生。
在最简单的情况下,我有一个只有一条记录的数据库表。我尝试创建一个具有相同 ID 的新记录,但我得到了预期的 IntegrityError
。如果我随后尝试在该数据库上运行任何其他查询命令,我将得到如上所述的 InternalError
。
sqlite 数据库不会发生这种情况。
我已经重新安装了 peewee 和 psycopg2,但没有用。
我错过了什么?
最佳答案
尝试在 Database
类中设置 autorollback=True
。您可以关注文档 here
您的问题已在 this issue 中已知
关于python - 为什么我在一个失败的命令后得到所有后续命令的 peewee.InternalError,使用 peewee ORM 和 posgresql?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52899051/