title: Declarative SQLAlchemy CREATE SQLITE in memory tables
body: <p>This is how I setup my database for an application (in Flask):</p>
  
  <pre><code>from sqlalchemy.engine import create_engine
  from sqlalchemy.orm import scoped_session, create_session
  from sqlalchemy.ext.declarative import declarative_base
  
  engine = None
  db_session = scoped_session(lambda: create_session(bind=engine,
                                                     autoflush=False, autocommit=False, expire_on_commit=True))
  
  Base = declarative_base()
  Base.query = db_session.query_property()
  
  def init_engine(uri, **kwargs):
      global engine
      engine = create_engine(uri, **kwargs)
  
      Base.metadata.create_all(bind=engine)
  
      return engine
  </code></pre>
  
  <p>If I connect to a file database that has had tables created already, everything works fine, but using <strong>sqlite:///:memory:</strong> as a target database gives me:</p>
  
  <pre><code>OperationalError: (OperationalError) no such table: users u'DELETE FROM users' ()
  </code></pre>
  
  <p>when querying like so for ex.:</p>
  
  <pre><code>UsersTable.query.delete()
  db_session.commit()
  </code></pre>
  
  <p>I am accessing this code from a unit test. What is the problem?</p>
  
  <p>Thanks</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Working setup of the application:</p>
  
  <pre><code>app = Flask(__name__)
  app.config.from_object(__name__)
  app.secret_key = 'XXX'
  
  # presenters
  from presenters.users import users
  
  # register modules (presenters)
  app.register_module(users)
  
  # initialize the database
  init_engine(db)
  </code></pre>