Trapping MySQLdb warnings

T

Tim Johnson

Using Python 2.6.5 on linux.

When using MySQLdb I am getting warnings printed to stdout, but I would
like to trap, display and log those warnings.

In the past I have used _mysql_exceptions.Warning, but that approach
is not working in this case.

My cursor is created with the relevant following code:

## connection object
self.__conn = MySQLdb.connect(db = self.__db,
host = self.__host, user = self.__user,
passwd = self.__passwd)

## cursor object
self.__rdb = self.__conn.cursor()
## And implemented as :
try :
self.__rdb.execute(S)
except _mysql_exceptions.Warning,e:
raise e ## replace with log(e)

What else needs to be done?
TIA
 

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,774
Messages
2,569,596
Members
45,143
Latest member
SterlingLa
Top