Re: InternalError Exception
Jan UrbaĆski <[email protected]> Fri, 28 May 2010 15:57:11 +0200
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Message-ID | <[email protected]> |
On 28/05/10 15:19, Joachim Worringen wrote: > On 05/28/2010 02:46 PM, Joachim Worringen wrote: >> On 05/28/2010 02:29 PM, Massa, Harald Armin wrote: >>> Joachim, >>> >>> you can ask PostgreSQL about the columns in a table: >> [..] >> >> Thanks, Harald - but in this case, this is a more complex workaround >> than just catching InternalError in addtion to ProgrammingError. >> >> I feel that InternalError should not be raised in the first place at >> this point (and normally, it isn't). > > Think I found the reason: I need to close() (or somehow reset?) the > cursor before proceeding after a ProgrammingError exception. Actually, you need to rollback the transaction (call .rollback() on the connection object). PostgreSQL will not allow you to execute anything in a transaction that had an error until you rollback, and psycopg2 cursors automatically create a transaction the first time you use them. Cheers, Jan