try - except. How to identify errors unknown in advance?

F

Frederic Rentsch

Hi all,


I'd like to log MySQL errors. If I do:

try: (command)
except MySQLdb.OperationalError, e: print e

I may get something like:

(1136, "Column count doesn't match value count at row 1")

If I don't know in advance which error to expect, but on the contrary
want to find out which error occurred, I can catch any error by omitting
the name:

except: (handle)

But now I don't have access to the error message 'e'. I'm sure there's a
way and it's probably ridiculously simple.

Frederic
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top