python - DatabaseError : current transaction is aborted, 命令在事务 block 结束之前被忽略?

标签 python django postgresql psycopg2

我收到了很多错误消息:

"DatabaseError: current transaction is aborted, commands ignored until end of transaction block"

从 python-psycopg 更改为 python-psycopg2 作为 Django 项目的数据库引擎之后。

代码保持不变,只是不知道那些错误来自哪里。

最佳答案

当查询产生错误并且您尝试运行另一个查询而不首先回滚事务时,这就是 postgres 所做的。 (您可能会将其视为一项安全功能,以防止您破坏数据。)

要解决此问题,您需要找出代码中执行错误查询的位置。使用 log_statement 可能会有所帮助和 log_min_error_statement您的 postgresql 服务器中的选项。

关于python - DatabaseError : current transaction is aborted, 命令在事务 block 结束之前被忽略?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2979369/

相关文章:

python - .string 和 .text BeautifulSoup 之间的区别

python - 如何模拟Python中的模块但不是所有方法

python - Django 查询集 : filter by the value of another field

postgresql - pg_restore 警告 : errors ignored on restore: 62

python - 在python中向某个字符串添加空格

python - Django 表单在单个 HTML 中多次使用并避免重复的 id

django - 压缩发送到django服务器的请求数据

django - is_valid() 与 clean() django 形式

sql - 如何使用 TypeORM 创建这个 ViewEntity?

sql - Postgresql to_char 大大减慢了查询速度