PYTHON MYSQL mysqldb错误级别,不显示warning

Here is a quick three line snippet that will suppress all of those annoying warning messages from MySQL when using MySQLdb:

view source print ?
1. from warnings import filterwarnings
2. import MySQLdb as Database
3. filterwarnings('ignore', category = Database.Warning)

To re-enable the warnings later on:

view source print ?
1. from warnings import resetwarnings
2. resetwarnings()

More about the warnings Python standard library:
http://docs.python.org/library/warnings.html

你可能感兴趣的:(mysql,python,database,library,Warnings)