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


Groups > comp.lang.python > #7720

Trapping MySQLdb warnings

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <tim@johnsons-web.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.020
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'warnings': 0.05; 'python': 0.08; 'done?': 0.09; 'linux.': 0.09; 'received:64.4': 0.09; 'cursor': 0.16; 'case.': 0.16; 'object': 0.26; 'raise': 0.28; 'skip:_ 20': 0.28; 'host': 0.29; 'to:addr:python-list': 0.33; 'header:User-Agent:1': 0.35; 'else': 0.35; 'using': 0.35; 'charset :us-ascii': 0.36; 'created': 0.36; 'log': 0.36; 'connection': 0.37; 'but': 0.38; 'implemented': 0.38; 'skip:s 20': 0.39; 'user': 0.39; 'printed': 0.39; 'to:addr:python.org': 0.39; 'getting': 0.40; 'relevant': 0.69
Date Wed, 15 Jun 2011 17:58:37 -0800
From Tim Johnson <tim@johnsons-web.com>
To Python ML <python-list@python.org>
Subject Trapping MySQLdb warnings
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
Organization AkWebsoft
User-Agent Mutt/1.5.20 (2009-06-14)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.9.1308189527.1164.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 82.94.164.166
X-Trace 1308189528 news.xs4all.nl 49177 [::ffff:82.94.164.166]:46464
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:7720

Show key headers only | 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