可以在mysql python中自定义errorhandler吗?(使用peewee)
我正在围绕可以在mysql python中自定义errorhandler吗?(使用peewee),python,mysql-python,peewee,Python,Mysql Python,Peewee,我正在围绕mysql-python编写一个mibbleware。目的是将所有mysql错误包装到我自己的处理程序中,而不是抛出异常并破坏逻辑 我的中间件是这样使用的peewee def my_hander(connection, cursor, errorclass, errorvalue): pass # my customized middleware logic here db = peewee.MySQLDatabase('backend', host= .... ) db.g
mysql-python
编写一个mibbleware。目的是将所有mysql错误包装到我自己的处理程序中,而不是抛出异常并破坏逻辑
我的中间件是这样使用的peewee
def my_hander(connection, cursor, errorclass, errorvalue):
pass # my customized middleware logic here
db = peewee.MySQLDatabase('backend', host= .... )
db.get_conn().errorhandler = my_hander
然而,不管我怎么做,我的_处理程序
都不会被触发,异常会像往常一样转到peewee&mysql
我的问题是,是否有任何规范的方法让mysql python向我自己的处理程序抛出异常,而不是转到MySQLdb/connections.py:def defaulterrorhandler()
Python 2.7,Ubuntu 12.04,其他使用最新版本的libs