Skip to content

Instantly share code, notes, and snippets.

@8maki
Created March 21, 2014 10:46
Show Gist options
  • Select an option

  • Save 8maki/9683619 to your computer and use it in GitHub Desktop.

Select an option

Save 8maki/9683619 to your computer and use it in GitHub Desktop.
ScrapyでItem Pipelineにsettingsを渡す方法 ref: http://qiita.com/8maki/items/7d994fb730d2a6089e45
class MySQLStorePipeline(object):
@classmethod
def from_settings(cls, settings):
return cls(settings.get('DB_SETTING'))
def __init__(self, db_settings):
db.init_session(db_settings)
def process_item(self, item, spider):
shop = Shop(
brand_id=1,
name=item['name'],
address=item['address'])
db.db_session.add(shop)
db.db_session.commit()
return item
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment