0
我正在使用this scrapy管道。如果insert_record函数中的sql存在任何错误,它将自动失败。例如,如果一个列名是误拼写,这样异常处理使用MySQL与扭曲的adbapi和scrapy
def _insert_record(self, tx, item):
print "before tx.execute"
result = tx.execute(
""" INSERT INTO table(col_one, col_typo, col_three) VALUES (1,2,3)"""
)
print "after tx.execute"
if result > 0:
self.stats.inc_value('database/items_added')
那么没有什么是后“之前执行”输出。有一个handle_error方法,但是这也没有被调用。我怎样才能捕捉并处理这些错误?