Error current transaction is aborted commands ignored until end of transaction block

0 votes

I got a lot of errors with the message :

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

after changed from python-psycopg to python-psycopg2 as Django project's database engine.

The code remains the same, just don't know where those errors are from.

Aug 3, 2020 in Python by kartik
• 37,510 points
163 views

1 answer to this question.

0 votes

Hello @kartik,

To get rid of the error, roll back the last (erroneous) transaction after you've fixed your code:

from django.db import transaction
transaction.rollback()

You can use try-except to prevent the error from occurring:

from django.db import transaction, DatabaseError
try:
    a.save()
except DatabaseError:
    transaction.rollback()

Hope it helps!!
Thank You!!

answered Aug 3, 2020 by Niroj
• 82,720 points

Related Questions In Python

0 votes
1 answer

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

Hello @kartik, To get rid of the error, roll ...READ MORE

answered May 6, 2020 in Python by Niroj
• 82,720 points
265 views
0 votes
0 answers

Excel .json Import Error: The Type of Current Preview Value is Too Complex to Display

Main Problem: I'm trying to import .json to excel ...READ MORE

Mar 14, 2020 in Python by Tarık
• 120 points
505 views
0 votes
0 answers

what is the purpose of the argument 'end' in the print function?

is it necessary to use this argument ...READ MORE

May 9, 2019 in Python by Waseem
• 4,540 points
82 views
0 votes
0 answers

Size is (121,512,512). Error is coming as : IndexError: index 152 is out of bounds for axis 0 with size 121.

def nodule_detect(nodules,j,numpyImage, numpyOrigin, numpySpacing): ...READ MORE

Jan 28, 2020 in Python by anonymous
• 150 points
3,192 views
0 votes
1 answer

How to temporarily disable a foreign key constraint in MySQL?

Hello @kartik, To turn off foreign key constraint ...READ MORE

answered Jun 23, 2020 in Python by Niroj
• 82,720 points
787 views
0 votes
1 answer

How do I use Django templates without the rest of Django?

Hello @kartik, Let's say you have this important ...READ MORE

answered Jun 23, 2020 in Python by Niroj
• 82,720 points
322 views
0 votes
1 answer

Error: current transaction is aborted, commands ignored until end of transaction block?

Hii kartik, To get rid of the error, roll ...READ MORE

answered Apr 23, 2020 in Python by Niroj
• 82,720 points
2,725 views
+1 vote
1 answer