Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/328.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
可以在mysql python中自定义errorhandler吗?(使用peewee)_Python_Mysql Python_Peewee - Fatal编程技术网

可以在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