Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Newpass(object):
- def __init__(self):
- self.connection = pymysql.connect(host='localhost',
- user='root',
- password='',
- db='newdb',
- charset='utf8mb4',
- cursorclass=pymysql.cursors.DictCursor
- )
- self.cursor = self.connection.cursor()
- def process_item(self,item,spider):
- try:
- sql = "INSERT INTO prothomalodata (serial,papername, newstitle, releasedate, collectionDate, url, newscontent, imagelink, vidlink) VALUES ( %s,%s,%s,%s,%s,%s,%s)"
- self.cursor.execute(sql,(item['papername'].encode('utf8'),
- item['title'].encode('utf8'),
- item['released'].encode('utf8'),
- item['url'].encode('utf8'),
- item['content'].encode('utf8'),
- '0'.encode('utf8'),
- '0'.encode('utf8'),)
- )
- self.connection.commit()
- self.connection.close()
- except pymysql.Error as e:
- print e
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement