[Tutor] Trapping warnings from MySQLdb
tim at johnsons-web.com
Tue Apr 14 03:54:21 CEST 2009
On Monday 13 April 2009, Kent Johnson wrote:
> >From a quick look at MySQLdb-1.2.2, it seems to be using the python
> std lib module warnings to report warnings.
> >From the warnings docs, it seems like warnings.simplefilter() is what
> you are looking for. Try this, perhaps in your wrapper module:
> import warnings
> import MySQLdb
> warnings.simplefilter("error", MySQLdb.Warning)
> I think that will tell the warnings module to treat MySQLdb.Warning as an
Yes! That is what I was looking for.
Here's the code (in my wrapper class)
self._connect_method = 'row'
print("<BR>SQL = %s<br>" % (s)) #DEBUG st
## and the interface:
## give user ad hoc analysis of the offending cmd
## Thanks a lot Ken
More information about the Tutor