SHARE
TWEET

Untitled

a guest Aug 17th, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import pymysql.cursors
  2. class MySQLPipeline(object):
  3.     def __init__(self):
  4.         self.connect = pymysql.connect(
  5.             host='127.0.0.1',  
  6.             port=3306,  
  7.             db='xxxx',  
  8.             user='root',  
  9.             passwd='xxxx',  
  10.             charset='utf8',  
  11.             use_unicode=True)
  12.         self.cursor = self.connect.cursor()
  13.  
  14.     def process_item(self, item, spider):
  15.         self.cursor.execute("sql_insert_command")
  16.         self.connect.commit()
  17.         return item
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top