Skip to content
Snippets Groups Projects
Commit 6b6a846b authored by Vermaat's avatar Vermaat
Browse files

Conveniently create tables on first use for in-memory SQLite

parent 6c3290a9
No related branches found
No related tags found
No related merge requests found
......@@ -42,6 +42,13 @@ def create_engine():
connect_args={'check_same_thread': False},
poolclass=StaticPool)
engine = sqlalchemy.create_engine(url, **options)
# For convenience, we also create tables if we're using an SQLite
# in-memory database. By definition they won't yet exist
Base.metadata.create_all(engine)
return engine
return sqlalchemy.create_engine(url, **options)
......
......@@ -161,9 +161,7 @@ def setup_database(alembic_config_path=None, destructive=False):
if destructive:
db.Base.metadata.drop_all(db.session.get_bind())
db.Base.metadata.create_all(db.session.get_bind())
db.session.commit()
if alembic_config_path:
context = MigrationContext.configure(db.session.connection())
......
......@@ -162,7 +162,6 @@ def database():
Fixture for database table definitions.
"""
Base.metadata.create_all(session.get_bind())
session.commit()
def hg19():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment