SQLite3 trapping OperationalError

jim-on-linux inq1ltd at verizon.net
Fri Mar 9 13:14:48 EST 2007


pyhelp,

I set up a table in SQLite3.

While running other modules I want to know if a  
table exists.

SQL has a command "List Tables" but I don't think 
SQLlite3 has this command.

I've tried 
   cursor.execute("select * from debtor where key
    is not null ")

The table debtor does not exist so I get 
"OperationalError"
which I want to trap with try/except or some other 
way.

However python 2.5, 
except OperationalError: 
responds with 
"OperationalError" is not defined.

Ideas on how to determine if a table exists would 
be welcome.

jim-on-linux





More information about the Python-list mailing list