title: SQlAlchemy __tablename__ NameError
body: <p>I'm completely new to SQlAlchemy and, trying to get it, I wrote the following code:</p>
  
  <pre><code>from sqlalchemy import Column, String, Integer, ForeignKey
  from sqlalchemy.ext.declarative import declarative_base
  from sqlalchemy.orm import sessionmaker
  
  Base = declarative_base()
  
  class Collection(Base):
      __tablename__ == 'Collection'
      id = Column(Integer, primary_key=True)
      name = Column(String)
  
  
  class Sheet(Base):
      __tablename__ = 'sheet'
      id = Column(Integer, primary_key=True)
      name = Column(String(200), nullable=False)
      collection_id = Column(Integer, ForeignKey('collection.id'))
  
  def main():
      base_name = 'test.db'
      engine = create_engine('sqlite:///{}'.format(base_name))
      session = sessionmaker()
      session.configure(bind=engine)
      Base.metadata.create_all(engine)
  
  if __name__ == "__main__":
      main()
  </code></pre>
  
  <p>And when I run this script I get:</p>
  
  <blockquote>
    <p>NameError: name '<strong>tablename</strong>' is not defined</p>
  </blockquote>
  
  <p>What am I doing wrong?</p>