Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class QuotetutorialPipeline(object):
- def __init__(self):
- self.create_connection()
- self.create_table()
- def create_connection(self):
- self.conn = _sqlite3.connect("myquotes.db")
- self.curr = self.conn.cursor()
- def create_table(self):
- self.curr.execute("""DROP TABLE IF EXISTS quotes_tb""")
- self.curr.execute("""create table quotes_tb(
- title text,
- author text,
- tag text
- )""")
- def process_item(self, item, spider):
- self.store_db(item)
- print("Pipeline :" + item['title'][0])
- return item
- def store_db(self,item):
- self.curr.execute(""" insert into quotes_tb values (?,?,? )""", (
- item['title'][0],
- item['author'][0],
- item['tag']
- ))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement