import pymysql
class QunanPipeline:
def process_item(self, item, spider):
return item
class QunanmysqlPipeline:
def process_item(self, item, spider):
insert_sql = "insert into quietly value(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
self.cur.execute(insert_sql, [item['tit'], item['user_name'], item['date'], item['days'],
item['photo_nums'], item['fee'], item['people'], item['icon_view'],
item['icon_love'], item['icon_comment'], item['places'], item['places1']])
self.db.commit()
return item
def open_spider(self,spider):
self.db = pymysql.connect(host="127.0.0.1", user="root", password="123456",
database="quiet", port=3306, charset='utf8')
self.cur = self.db.cursor()
def close_spider(self,spider):
self.db.close()
self.cur.close()
输出结果
TypeError: not all arguments converted during string formatting
数据的格式你都写成了%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,这跟字段的格式要一致哦。
如有帮助,请点击我评论上方【采纳该答案】按钮支持一下。
报错已经提示你了,有些参数的类型不能转换成string
not all arguments converted during string formatting