异步入库报错(1136, "Column count doesn't match value count at row 1")
来源:4-13 提取详情页信息
qq_说什么谎言才不会被揭穿_03684187
2020-12-02
class LolItemLoader (ItemLoader):
#自定义itemloader,用于存储爬虫所抓取的字段内容
default_output_processor = TakeFirst()
class LolItem (scrapy.Item) : # 建立相应的字段
#define the fields for your item here like:
#name = scrapy.Field()
title = scrapy.Field()
categroy_id = scrapy.Field()
description = scrapy.Field()
content = scrapy.Field()
views = scrapy.Field()
realviews = scrapy.Field()
keywords = scrapy.Field()
thumb = scrapy.Field()
like_num = scrapy.Field()
comment_num = scrapy.Field()
updated_at = scrapy.Field()
created_at = scrapy.Field()
url_object_id = scrapy.Field()
def get_insert_sql(self):
insert_sql = """
insert into articles
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s,%s,%s) ON DUPLICATE KEY UPDATE url_object_id=VALUES(url_object_id)
"""
params = (
self.get("title", ""),
self.get("categroy_id", ""),
self.get("description", ""),
self.get("content", ""),
self.get("views", 0),
self.get("realviews", 0),
self.get("keywords", ''),
self.get("thumb", ""),
self.get("like_num", 0),
self.get("comment_num", 0),
self.get("updated_at", "0000-00-00"),
self.get("created_at", "0000-00-00"),
self.get("url_object_id"),
)
return insert_sql, params
这里写的有什么问题吗?都是参考教程写法的呢。
写回答
3回答
-
qq_说什么谎言才不会被揭穿_03684187
提问者
2020-12-04
解决了是sql语句有问题,老师你的git代码有问题哦,insert_sql = """
insert into articles
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s,%s,%s) ON DUPLICATE KEY UPDATE url_object_id=VALUES(url_object_id)
"""这个有问题的
012020-12-07 -
bobby
2020-12-03
你留下qq 我加你看看 估计是其他的sql不是此处的sql 从报错来看确实是数量不匹配
00 -
qq_说什么谎言才不会被揭穿_03684187
提问者
2020-12-02
我debug看了params 参数长度也是13个,为什么还会报这个错误呢
00
相似问题