Hi,

I'm looking for a way to check for a table's existance. I know I can do it 
in 2 queries, once for checking the table and one for running the query, 
but I'd prefer to do it in one query with a try-except block.

What is the best way to do this? I'm using psycopg2 and I see that the 
raised error is "psycopg2.errors.UndefinedTable". However I cannot catch 
for this error, I can only catch for "sqlalchemy.exc.ProgrammingError".

How can I catch specifically for psycopg2.errors.UndefinedTable inside 
sqlalchemy.exc.ProgrammingError?

Or is there a better way to check for a table's existance? Since it'll be 
in an API I'd prefer to keep the query count low.

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/a7bba66c-f29d-42e3-a911-d608677846b2%40googlegroups.com.

Reply via email to