【发布时间】:2016-03-07 08:44:47
【问题描述】:
我正在使用thisscrapy 管道。如果 insert_record 函数中的 sql 有任何错误,它会静默失败。例如,如果列名拼写错误,像这样
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 方法,但也没有调用。如何捕捉和处理此类错误?
【问题讨论】:
标签: mysql python-2.7 scrapy twisted