def process_item(self, item, spider): data = dict(item) #mysql插入数据 keys = ','.join(data.keys()) values = ','.join(['%s'] * len(data)) sql = 'INSERT INTO {table}({keys}) VALUES({values})'.format(table=self.sheetname, keys=keys, values=values) self.cursor.execute(sql,tuple(data.values())) self.conn.commit() #self.cursor.close() #self.conn.close() return item 我怎么判断存储到最后一个然后执行self.cursor.close() self.conn.close()
周萝卜