Exemple #1
0
    def process_item(self, item, spider):
        """Save deals in the database.

        This method is called for every item pipeline component.

        """

        session = self.Session()
        # Unpack deals item
        deal = Deals(**item)

        try:
            # Add deal to session
            session.add(deal)
            # Commit changes to db
            session.commit()

        except:
            session.rollback()
            raise

        finally:
            # Close session
            session.close()

        return item
Exemple #2
0
	def process_item(self, item, spider):
		session = self.Session()
		deal = Deals(**item)
		try:
			session.add(deal)
			session.commit()
		except:
			session.rollback()
			raise
		finally:
			session.close()
		return item
Exemple #3
0
	def process_item(self, item, spider):
		"""Save deals in the database."""
		session = Self.Session()
		deal = Deals(**item)

		try:
			session.add(deal)
			session.commit()
		except:
			session.rollback()
			raise
		finally:
			session.close()
		return item
Exemple #4
0
	def process_item(self, item, spider):
		"""Save deals in the database.
		This method is called for every item pipeline component.
		"""
		session = self.Sesson()
		deal = Deals(**item)

		try:
			session.add(deal)
			session.commit()
		except session.rollback()
			raise
		finally:
			session.close()

		return item
Exemple #5
0
    def process_item(self, item, spider):
        """Save deals in the database.
		
		This method is called for every item pipeline component.
		
		"""
        session = self.Session()  # establish session with database
        deal = Deals(**item)  # unpack an item (data of our scraped deal)

        try:
            session.add(deal)  # add deal to our database
            session.commit()  # put deal into database and commit transaction
        except:
            session.rollback()  # in case something goes awry
            raise
        finally:
            session.close(
            )  # whether or not we are successful, close the connection

        return item