簡體   English   中英

django / postgresql當前事務中止,命令被忽略,直到事務塊結束

[英]django/postgresql current transaction is aborted, commands ignored until end of transaction block

我收到上述錯誤,在提交模型表格時,我嘗試了-

1。

from django.db import transaction
transaction.rollback()

2

from django import db
from django.db.backends.util import CursorDebugWrapper
old_execute = CursorDebugWrapper.execute
old_execute_many = CursorDebugWrapper.executemany

def execute_wrapper(*args, **kwargs):
    try:
        old_execute(*args, **kwargs)
    except Exception, ex:
        logger.error("Database error:\n%s" % ex)
        db.close_connection

def excecute_many_wrapper(*args, **kwargs):
    try:
        old_execute_many(*args, **kwargs)
    except Exception, ex:
        logger.error("Database error:\n%s" % ex)
        db.close_connection

CursorDebugWrapper.execute = execute_wrapper
CursorDebugWrapper.executemany = excecute_many_wrapper

3

from django.db import connection
connection._rollback()

4

manage.py migrate 

要么

manage.py syncdb

然后重新提交模型表格,似乎什么也沒有發生。

我怎樣才能解決這個問題?

您需要顯示postgresql日志以找出問題所在,其中有錯誤的SQL查詢。

tail -f /var/lib/pgsql/data/pg_log/postgresql-Thu.log

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM