Re: Trapping MySQLdb warnings

2011-06-16 Thread Tim Johnson
* Tim Johnson t...@johnsons-web.com [110615 18:53]: * geremy condra debat...@gmail.com [110615 18:03]: On Wed, Jun 15, 2011 at 6:58 PM, Tim Johnson t...@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

Re: Trapping MySQLdb warnings

2011-06-16 Thread Terry Reedy
On 6/16/2011 11:55 AM, Tim Johnson wrote: * Tim Johnsont...@johnsons-web.com [110615 18:53]: * geremy condradebat...@gmail.com [110615 18:03]: On Wed, Jun 15, 2011 at 6:58 PM, Tim Johnsont...@johnsons-web.com wrote: Using Python 2.6.5 on linux. When using MySQLdb I am getting warnings

Re: Trapping MySQLdb warnings

2011-06-16 Thread srinivas hn
Hi Tim, Use this method it will sort tour problem. def do_query(insert_query): import warnings with warnings.catch_warnings(): warnings.simplefilter('error', MySQLdb.Warning) try: cursor.execute(insert_query) conn.commit() return 'Success' except MySQLdb.Error,

Re: Trapping MySQLdb warnings

2011-06-16 Thread Tim Johnson
* Terry Reedy tjre...@udel.edu [110616 10:50]: On 6/16/2011 11:55 AM, Tim Johnson wrote: * Tim Johnsont...@johnsons-web.com [110615 18:53]: * geremy condradebat...@gmail.com [110615 18:03]: On Wed, Jun 15, 2011 at 6:58 PM, Tim Johnsont...@johnsons-web.com wrote: Using Python 2.6.5 on

Re: Trapping MySQLdb warnings

2011-06-16 Thread Tim Johnson
* Terry Reedy tjre...@udel.edu [110616 10:50]: ... Substitute specific MySQLdb warning class, whatever it is, for Warning. Hmm! Consider the following code: try : self.__rdb.execute(S) raise MySQLdb.Warning('danger, danger Monte Python') ## just for grins except MySQLdb.Warning,e:

Re: Trapping MySQLdb warnings

2011-06-16 Thread Terry Reedy
On 6/16/2011 3:01 PM, Tim Johnson wrote: * Terry Reedytjre...@udel.edu [110616 10:50]: The machinery in the warnings module is only for instances of subsclasses of Warning. Are the warnings from MySQLdb properly such objects? If so, what class are they? The warnings are sent directly to

Re: Trapping MySQLdb warnings

2011-06-16 Thread Tim Johnson
* srinivas hn hnsr...@gmail.com [110616 11:06]: Hi Tim, Use this method it will sort tour problem. def do_query(insert_query): import warnings with warnings.catch_warnings(): warnings.simplefilter('error', MySQLdb.Warning) try: cursor.execute(insert_query)

Re: Trapping MySQLdb warnings

2011-06-16 Thread Tim Johnson
* srinivas hn hnsr...@gmail.com [110616 11:06]: Hi Tim, import warnings with warnings.catch_warnings(): warnings.simplefilter('error', MySQLdb.Warning) try: cursor.execute(insert_query) conn.commit() return 'Success' except MySQLdb.Error, error:

Trapping MySQLdb warnings

2011-06-15 Thread 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

Re: Trapping MySQLdb warnings

2011-06-15 Thread geremy condra
On Wed, Jun 15, 2011 at 6:58 PM, Tim Johnson t...@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

Re: Trapping MySQLdb warnings

2011-06-15 Thread Tim Johnson
* geremy condra debat...@gmail.com [110615 18:03]: On Wed, Jun 15, 2011 at 6:58 PM, Tim Johnson t...@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. . Have you