Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #7721 > unrolled thread

Re: Trapping MySQLdb warnings

Started bygeremy condra <debatem1@gmail.com>
First post2011-06-15 19:03 -0700
Last post2011-06-15 19:03 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Trapping MySQLdb warnings geremy condra <debatem1@gmail.com> - 2011-06-15 19:03 -0700

#7721 — Re: Trapping MySQLdb warnings

Fromgeremy condra <debatem1@gmail.com>
Date2011-06-15 19:03 -0700
SubjectRe: Trapping MySQLdb warnings
Message-ID<mailman.10.1308189796.1164.python-list@python.org>
On Wed, Jun 15, 2011 at 6:58 PM, Tim Johnson <tim@johnsons-web.com> wrote:
> 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?

Have you tried http://docs.python.org/library/warnings.html#temporarily-suppressing-warnings
?

Geremy Condra

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web