title: SQLAlchemy Error Table not found
body: <p>I am new to using sqlAlchemy and i keep getting this error when i try inserting a data entry. Please tell me what i am doing wrong.</p>
  
  <p>test.py code:</p>
  
  <pre><code>import sys
  import sqlalchemy
  from sqlalchemy.orm import sessionmaker
  from sqlalchemy import Column,ForeignKey,Integer,String
  from sqlalchemy.ext.declarative import declarative_base
  from sqlalchemy.orm import relationship
  from sqlalchemy import create_engine
  
  
  engine = create_engine('sqlite:///restaurantmenu.db')
  Base = declarative_base()
  
  
  class Restaurant(Base):
     __tablename__ = "restaurant"
      name = Column(String(80),nullable=False)
      id = Column(Integer,primary_key=True)
  
  
  class MenuItem(Base):
      __tablename__ = 'menu_item'
      name = Column(String(80),nullable=False)
      id = Column(Integer,primary_key = True)
      course = Column(String(250))
      description = Column(String(250))
      price = Column(String(9))
      restaurant_id = Column(Integer,ForeignKey('restaurant.id'))
      restaurant = relationship(Restaurant)
  Base.metadata.create_all(engine)
  </code></pre>
  
  <p>accessDatabase.py code</p>
  
  <pre><code>import sys
  from sqlalchemy.orm import sessionmaker
  from sqlalchemy import create_engine
  from test import Base,Restaurant,MenuItem
  
  engine = create_engine('sqlite:///restaurantmenu.db')
  Base.metadata.bind = engine
  DBSession = sessionmaker(bind=engine,autoflush=False)
  session = DBSession()
  MyFirstRestaurant = Restaurant(name = "Pizza Palace")
  session.add(MyFirstRestaurant)
  session.commit()
  session.query(Restaurant).all()
  </code></pre>
  
  <p>the problem occurs when I run accessDatabase.py and at the line session.commit</p>
  
  <p>error here:</p>
  
  <pre><code>   sqlalchemy.exc.OperationalError: 
      (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block 
  if this flush is occurring prematurely) 
  (sqlite3.OperationalError) no such table: restaurant [SQL: 'INSERT INTO restaurant (name) VALUES (?)'] [parameters: ('Pizza Palace',)] 
  (Background on this error at: http://sqlalche.me/e/e3q8)
  </code></pre>