• Register
0 votes

Problem :

I am facing a lot of errors with the below message :

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

Whenever I tried to change from the python-psycopg to the python-psycopg2 as my Django project's database engine.

My code remains the same, just unable to know where those errors are coming from ?

7.5k points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

In my recent experience, the mentioned errors happen this way:

    # transaction on the DB is now bad
    # transaction on db is still very bad
    # raises the transaction error

There is nothing wrong with my second query, but since my real error was caught, so my second query is the one that will raise my very less informative error.

This only happens if my except clause catches the IntegrityError or any other exception from the low level database exception, If you can catch something like DoesNotExist then this error will not show up, as DoesNotExist does not corrupt my transaction.

So the lesson here is don't do the try/except/pass.


If you get above mentioned error while in the interactive shell and you need the quick fix, then simply do this:

from django.db import connection


38.6k points

Related questions

0 votes
1 answer 148 views
Problem : I am having hell lot of troubles because of below error message internalerror: current transaction is aborted, commands ignored until end of transaction block
asked Nov 14, 2019 peterlaw 6.9k points
0 votes
1 answer 25 views
Problem: Has anyone had this complication before : Error: current transaction is aborted, commands ignored until end of transaction block?
asked Jun 13 Chi Omega 168k points
0 votes
1 answer 13 views
Problem: I tried to get executed with my except: statement... while attempt to oppose the functionality of UNIQUE constraint..But ended with exceptional error.. The Postgresql database table already contains the row that I have used, but it works well on inserting unrepeated ... fetchall() print(row) db=database() db.insert("The News","AparnaKumar",1995,234569654) db.view() db.search(year=1995)
asked Apr 24 munim01 21k points
0 votes
1 answer 7 views
Problem: Error: pg_config executable not found?
asked Jul 25 Nahil 128k points
0 votes
1 answer 11 views
Problem: Duplicate key value violates unique constraint django
asked Jun 26 Shifa 18.2k points
0 votes
1 answer 29 views
Problem: Where can I get help: Django.db .utils.operationalerror: could not connect to server: connection refused
asked Jun 14 nila 121k points
0 votes
1 answer 499 views
Problem : I am not very sure how can I fix the below issue I have really no idea about why am I facing below error while trying to do the runserver: Performing system checks... System check identified no issues (0 silenced). Unhandled exception in thread ... server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
asked Dec 25, 2019 alecxe 7.5k points
0 votes
1 answer 67 views
Problem: I need someone’s help to fix it .. error pg_config executable not found
asked Mar 19 Ifra 43.4k points
0 votes
1 answer 94 views
Problem: The current path, account/login/, didn't match any of these?What is the problem here?. The redirect works, I have a feeling its in urlpatterns but cannot for the life figure it out. Driving me crazy today. Thanks for the help and sorry for the essay!
asked May 4 sumaiya simi 43.9k points
0 votes
1 answer 288 views
Problem: Facing this error message: Unchecked runtime.lasterror: could not establish connection. receiving end does not exist.
asked Mar 14 Wafa Abu Yousef 6.1k points