title: How to set crawler parameter from scrapy spider
body: <p><a href="https://i.stack.imgur.com/ZnKNE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZnKNE.png" alt="enter image description here"></a></p>
  
  <p>I am trying to pass a db table parameter set in a scrapy spider to a pipeline object to follow up question <a href="https://stackoverflow.com/questions/41043970/how-to-pass-parameter-to-a-scrapy-pipeline-object">How to pass parameter to a scrapy pipeline object</a>. based on the answer to this question I have:</p>
  
  <pre><code>@classmethod
  def from_crawler(cls, crawler):
      # Here, you get whatever value was passed through the "table" parameter
      settings = crawler.settings
      table = settings.get('table')
  
      # Instantiate the pipeline with your table
      return cls(table)
  
  def __init__(self, table):
      _engine = create_engine("sqlite:///data.db")
      _connection = _engine.connect()
      _metadata = MetaData()
      _stack_items = Table(table, _metadata,
                           Column("id", Integer, primary_key=True),
                           Column("detail_url", Text),
      _metadata.create_all(_engine)
      self.connection = _connection
      self.stack_items = _stack_items
  </code></pre>
  
  <p>My spider looks like:</p>
  
  <pre><code>class my_Spider(Spider):
  
      name = "my"
  
      def from_crawler(self, crawler, table='test'):
          pass
  
  
      def start_requests(self):
  
         .....
  </code></pre>
  
  <p>I added the from_crawler line based on <a href="https://doc.scrapy.org/en/latest/topics/spiders.html#scrapy.spiders.Spider.from_crawler" rel="nofollow noreferrer">https://doc.scrapy.org/en/latest/topics/spiders.html#scrapy.spiders.Spider.from_crawler</a> , but now I'm getting:</p>
  
  <pre><code>  File "C:\ENVS\virtalenvs\contact\lib\site-packages\twisted\internet\defer.py", line 1128, in _inlineCallbacks
      result = g.send(result)
    File "C:\ENVS\virtalenvs\contact\lib\site-packages\scrapy\crawler.py", line 90, in crawl
      six.reraise(*exc_info)
    File "C:\ENVS\virtalenvs\contact\lib\site-packages\scrapy\crawler.py", line 71, in crawl
      self.spider = self._create_spider(*args, **kwargs)
    File "C:\ENVS\virtalenvs\contact\lib\site-packages\scrapy\crawler.py", line 94, in _create_spider
      return self.spidercls.from_crawler(self, *args, **kwargs)
  TypeError: unbound method from_crawler() must be called with My_Spider instance as first argument (got Crawler instance instead)
  </code></pre>
  
  <p>How can I get this working?</p>
  
  <p>EDIT :</p>
  
  <p>after changing the class method I'm getting:</p>
  
  <pre><code>exceptions.TypeError: __init__() takes exactly 1 argument (2 given)
  2016-12-09 15:47:37 [twisted] CRITICAL: 
  Traceback (most recent call last):
    File "C:\ENVS\virtalenvs\contact\lib\site-packages\twisted\internet\defer.py", line 1128, in _inlineCallbacks
      result = g.send(result)
    File "C:\ENVS\virtalenvs\contact\lib\site-packages\scrapy\crawler.py", line 90, in crawl
      six.reraise(*exc_info)
    File "C:\ENVS\virtalenvs\contact\lib\site-packages\scrapy\crawler.py", line 72, in crawl
      self.engine = self._create_engine()
    File "C:\ENVS\virtalenvs\contact\lib\site-packages\scrapy\crawler.py", line 97, in _create_engine
      return ExecutionEngine(self, lambda _: self.stop())
    File "C:\ENVS\virtalenvs\contact\lib\site-packages\scrapy\core\engine.py", line 69, in __init__
      self.scraper = Scraper(crawler)
    File "C:\ENVS\virtalenvs\contact\lib\site-packages\scrapy\core\scraper.py", line 71, in __init__
      self.itemproc = itemproc_cls.from_crawler(crawler)
    File "C:\ENVS\virtalenvs\contact\lib\site-packages\scrapy\middleware.py", line 58, in from_crawler
      return cls.from_settings(crawler.settings, crawler)
    File "C:\ENVS\virtalenvs\contact\lib\site-packages\scrapy\middleware.py", line 36, in from_settings
      mw = mwcls.from_crawler(crawler)
    File "C:\ENVS\r2\my\my\pipelines.py", line 30, in from_crawler
      return cls(table_name)
  TypeError: __init__() takes exactly 1 argument (2 given)
  </code></pre>