Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement