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


Groups > comp.lang.python > #7720

Trapping MySQLdb warnings

Date 2011-06-15 17:58 -0800
From Tim Johnson <tim@johnsons-web.com>
Subject Trapping MySQLdb warnings
Organization AkWebsoft
Newsgroups comp.lang.python
Message-ID <mailman.9.1308189527.1164.python-list@python.org> (permalink)

Show all headers | View raw


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
-- 
Tim 
tim at johnsons-web dot com or akwebsoft dot com
http://www.akwebsoft.com

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Trapping MySQLdb warnings Tim Johnson <tim@johnsons-web.com> - 2011-06-15 17:58 -0800

csiph-web