数据入库问题
来源:6-19 保存数据到mysql中 -1
慕运维5061613
2020-07-25
老师我运行到这一步然后就出现一大堆错误,一脸茫然,试了很多方法都不行,也看了你的代码,找不到错误在哪
class ZhihuAnswerItem(scrapy.Item):
zhihu_id = scrapy.Field()
url = scrapy.Field()
question_id = scrapy.Field()
author_id = scrapy.Field()
content = scrapy.Field()
praise_num = scrapy.Field()
comments_num = scrapy.Field()
create_time = scrapy.Field()
update_time = scrapy.Field()
crawl_time =scrapy.Field()
def get_insert_sql(self):
insert_sql = """
insert into zhihu_answer(zhihu_id, url, question_id, author_id, content, praise_num, comments_num, create_time,
update_time, crawl_time)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
"""
create_time = datetime.datetime.fromtimestamp(self["create_time"])
update_time = datetime.datetime.fromtimestamp(self["update_time"])
params = list()
params.append(self["zhihu_id"][0])
params.append(self["url"][0])
params.append(self["question_id"][0])
params.append(self["author_id"][0])
params.append(self["content"][0])
params.append(self["praise_num"][0])
params.append(self["comments_num"][0])
params.append(self["create_time"][0])
params.append(self["update_time"][0])
params.append(self["crawl_time"][0])
return insert_sql,params
写回答
1回答
-
bobby
2020-07-27
你的handler_error函数中 打断点 看看具体的报错信息是什么
022020-07-30
相似问题