title: ProgrammingError: column "column" of relation "schema" does not exist
body: <p>I'm following this tutorial about using Scrapy with Postgres <a href="http://newcoder.io/scrape" rel="nofollow">http://newcoder.io/scrape</a>.  I'm new with postgres and very familiar with scrapy.</p>
  
  <p>Nowhere in the tutorial does it state anything about migrations so I think it intends to generate the tables using <code>DeclarativeBase.metadata.create_all(engine)</code> or within the contents of the code somewhere.</p>
  
  <p>my <code>models.py</code></p>
  
  <pre><code>from sqlalchemy import Table, create_engine, Column, Integer, String, DateTime
  from sqlalchemy.ext.declarative import declarative_base
  from sqlalchemy.engine.url import URL
  
  import settings
  
  
  DeclarativeBase = declarative_base()
  
  
  def db_connect():
      return create_engine(URL(**settings.DATABASE))
  
  def create_scores_table(engine):
      """"""
      DeclarativeBase.metadata.create_all(engine)
  
  class Scores(DeclarativeBase):
          __tablename__ = "scores"
  
          id = Column(Integer, primary_key=True)
          score = Column('score', String, nullable=True)
  </code></pre>
  
  <p>my <code>pipelines.py</code>:</p>
  
  <pre><code>from sqlalchemy.orm import sessionmaker
  from models import Scores, db_connect, create_scores_table
  
  class RrsportsPipeline(object):
  
  def __init__(self):
  
      engine = db_connect()
      create_scores_table(engine)
      self.Session = sessionmaker(bind=engine)
  
  
  def process_item(self, item, spider):
      session = self.Session()
      scores = Scores(**item)
      try:
          session.add(scores)
          session.commit()
      except:
          session.rollback()
          raise
      finally:
          session.close()
      return item    
  </code></pre>
  
  <p>I know the database is connecting correctly too with correct creds and database name.</p>
  
  <p>the full Traceback</p>
  
  <pre><code>Traceback (most recent call last):
    File "/usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py", line 588, in _runCallbacks
      current.result = callback(current.result, *args, **kw)
    File "/home/ubuntu/rgsports/rgsports/rgsports/pipelines.py", line 44, in process_item
      session.commit()
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 801, in commit
      self.transaction.commit()
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 392, in commit
      self._prepare_impl()
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 372, in _prepare_impl
      self.session.flush()
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 2019, in flush
      self._flush(objects)
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 2137, in _flush
      transaction.rollback(_capture_exception=True)
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/langhelpers.py", line 60, in __exit__
      compat.reraise(exc_type, exc_value, exc_tb)
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 2101, in _flush
      flush_context.execute()
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/unitofwork.py", line 373, in execute
      rec.execute(self)
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/unitofwork.py", line 532, in execute
      uow
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/persistence.py", line 174, in save_obj
      mapper, table, insert)
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/persistence.py", line 800, in _emit_insert_statements
      execute(statement, params)
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 914, in execute
      return meth(self, multiparams, params)
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/elements.py", line 323, in _execute_on_connection
      return connection._execute_clauseelement(self, multiparams, params)
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1010, in _execute_clauseelement
      compiled_sql, distilled_params
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1146, in _execute_context
      context)
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1341, in _handle_dbapi_exception
      exc_info
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/compat.py", line 202, in raise_from_cause
      reraise(type(exception), exception, tb=exc_tb, cause=cause)
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1139, in _execute_context
      context)
    File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 450, in do_execute
      cursor.execute(statement, parameters)
  ProgrammingError: (psycopg2.ProgrammingError) column "score" of relation "scores" does not exist
  
  LINE 1: INSERT INTO scores (score)
                                 ^
   [SQL: 'INSERT INTO scores (score) VALUES (%(score)s) RETURNING scores.id'] [parameters: {'score': u'114'}]
  </code></pre>
  
  <p>but when I run the spider: </p>
  
  <p><code>ProgrammingError: column "score" of relation "scores" does not exist</code></p>
  
  <p>Should I just create the table manually? If so, how? I'd prefer to have it within the code though. Is there something in my models that I'm missing? Or do I have to run models as some sort of deliberate migration?  I can't seem to trigger the tables to be built.</p>