MySQLdb module & error capturing

paula at merns.com paula at merns.com
Tue Jun 26 15:17:00 EDT 2001


I'm a little bit of a newbie so if this belongs on another list let 
me know.

I am trying to capture a _mysql.OperationalError that is returned by 
the MySQLdb module so that I can process it through error handling. 
Or even just print out the one bit (the error number and the error 
text) with out having the 5 layered traceback message showing every 
layer of my program. Sample error at bottom.

I have tried looking at the MySQLdb module and I have not noted 
direct error passing back to the calling program from the C API.

Anyone else know the answer?

I have been looking at the traceback module but I don't know enough 
about it to really figure this out.

Thanks for your help,
Paula

****Sample Code
>>> causeerror=decur.execute("select everything from everywhere")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/local/lib/python2.1/site-packages/MySQLdb.py", line 190, 
in execute    return self._query(query)
  File "/usr/local/lib/python2.1/site-packages/MySQLdb.py", line 290, 
in _query
    rowcount = self._BaseCursor__do_query(q)
  File "/usr/local/lib/python2.1/site-packages/MySQLdb.py", line 235, 
in __do_query
    db.query(q)
_mysql.OperationalError: (1146, "Table 'ZimbuT.everywhere' doesn't 
exist")   






More information about the Python-list mailing list