在我的python脚本中,我想捕获"数据截断列'xxx'"警告使用MySql查询我的查询.
我看到一些帖子提示下面的代码,但它没有用.
您是否知道在使用此代码之前是否必须导入某个特定模块或是否应调用某个选项/标志?
谢谢大家
Afeg
import MySQLdb
try:
cursor.execute(some_statement)
# code steps always here: No Warning is trapped
# by the code below
except MySQLdb.Warning, e:
# handle warnings, if the cursor you're using raises them
except Warning, e:
# handle warnings, if the cursor you're using raises them
Run Code Online (Sandbox Code Playgroud)