views:

634

answers:

1

I got a lot of "DatabaseError: current transaction is aborted, commands ignored until end of transaction block" errors after changed from python-psycopg to python-psycopg2 as Django project's database engine.

The code remains the same, just dont know where those errors are from.

+4  A: 

This is what postgres does when a query produces an error and you try to run another query without first rolling back the transaction. To fix it, you'll want to figure out where in the code that bad query is being executed. It might be helpful to use the log_statement and log_min_error_statement options in your postgresql server.

Forest
the problem is when I was using python-psycopg, no such errors raised. does psycopg2 implemented a different mechanism talking to postgres?
jack
The method of talking to the server probably doesn't matter, but it's possible that the version you used before somehow defaulted to autocommit mode while the new version does not. The error might still have occurred, but you could more easily have missed it. It's also possible that data type conversion or something else has changed since the old version. Regardless, the best fix is to track down the bad query so you can see what's wrong with it.
Forest