# -*- coding: utf-8 -*- import logging from database.models import Nevrax class NevraxPipeline(object): def process_item(self, item, spider): try: page = Nevrax.get(Nevrax.url == item['url']) q = Nevrax.update(**item).where(Nevrax.url == item['url']) q.execute() logging.info("Update item {}".format(page)) except Nevrax.DoesNotExist: page = Nevrax.create(**item) logging.info("Create item {}".format(page)) logging.info('Item {} stored in db'.format(page)) return item