2016-03-12 23 views
0

處理我有擦傷一個網站,並寫入到MySQL誤差scrapy和MySQL

import MySQLdb.cursors 

def __init__(self,stats): 
    self.dbpool = adbapi.ConnectionPool(<dbnam>,host=<host>,user=<user>,port=<port>,passwd=<pwd>, db=<dbname>, cursorclass=MySQLdb.cursors.DictCursor, charset='utf8', use_unicode=True) 

def process_item(self, item, spider): 
    query = self.dbpool.runInteraction(self._conditional_insert, item) 
    query.addErrback(self.handle_error) 


tx.execute("""INSERT INTO numbers ('{0}').format(", ".join(item['numbers']))) 

,出現以下錯誤手柄scrapy代碼:

def handle_error(self, e): 
    logging.error("This INSERT generated an ERROR") 

如何獲得錯誤描述輸出在屏幕上。我在網上搜索了很多,並且找不到解決方案。

在此先感謝您的幫助!

回答

0

畢竟這是一個簡單的問題。也許我誤解了文檔。

def handle_error(self, e): logging.info(e)