diff --git a/mutalyzer/db/__init__.py b/mutalyzer/db/__init__.py index 8282e824e5527d9c1b9ba6f98a548edecd565b93..3e4fc6ea9b8ae333977ac99e29ffb33eccc69a5e 100644 --- a/mutalyzer/db/__init__.py +++ b/mutalyzer/db/__init__.py @@ -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) diff --git a/mutalyzer/entrypoints/admin.py b/mutalyzer/entrypoints/admin.py index 613ba1974468a3fa6384167d09f8dd4315d0e4f9..d0458dbe941361748826d414be02172f869faf4b 100644 --- a/mutalyzer/entrypoints/admin.py +++ b/mutalyzer/entrypoints/admin.py @@ -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()) diff --git a/tests/fixtures.py b/tests/fixtures.py index d699912beb051ce53fc4c925c81c1e4019960a49..e25d018dc5b5b2392cb5170bd42bcae47063b4a1 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -162,7 +162,6 @@ def database(): Fixture for database table definitions. """ Base.metadata.create_all(session.get_bind()) - session.commit() def hg19():