【发布时间】:2011-01-07 07:38:08
【问题描述】:
在我的 python 脚本中,我想在我的查询中使用 MySql 捕获“数据被截断的列 'xxx'”警告。
我看到一些帖子建议使用下面的代码,但它不起作用。
您知道在使用此代码之前是否必须导入某些特定模块,或者是否应该调用某些选项/标志?
谢谢大家
阿费格
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
【问题讨论】: