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: 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 To: Python ML 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 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