?怎么插入到sql server数据库中,mssql?
这是我的代码 插入到mysql中 # -*- coding: utf-8 -*- import pymysql # Define your item pipelines here # # Don't forget to add your pipeline to the ITEM_PIPELINES setting # See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html class DoubanPipeline(object): def __init__(self): self.mydb = pymysql.connect(host="127.0.0.1",user="root",password="020202",db="douban",charset="utf8",use_unicode=True) self.cursor = self.mydb.cursor() def process_item(self, item, spider): insert_sql = """insert into movie(serial_number, movie_name, introduce, star, evaluate, describetion) values (%s, %s, %s, %s,%s,%s)""" # 使用`占位符 self.cursor.execute(insert_sql,(item['serial_number'],item['movie_name'],item['introduce'],item['star'],item['evaluate'],item['describetion'])) #用commit()才会提交到数据库 self.mydb.commit() def close_spider(self,spider): self.cursor.close() self.mydb.close()