Re: InternalError Exception

Jeremy Mason <[email protected]> Fri, 28 May 2010 09:21:52 -0400
Newsgroups gmane.comp.python.db.psycopg.devel
Message-ID <[email protected]>
On 5/28/10 8:46 AM, 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).
>
> Joachim

I use a query like:

SELECT count(column_name)
FROM information_schema.columns
WHERE table_name = 'mytable'
AND column_name = 'missing_column'

It returns 0 if the column is missing.  Although, information_schema is 
only available in Postgres 7.4 or later.

Jeremy