From 004bc9e705668f9294d9732bbd6e6d73ac784c2b Mon Sep 17 00:00:00 2001 From: Jason Stiles <99777116+stilesj-uchicago@users.noreply.github.com> Date: Tue, 31 May 2022 14:16:05 -0600 Subject: [PATCH] DEV-1174 changing the engine logic so that integration tests can be debugged in graphmanager --- indexd/utils.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/indexd/utils.py b/indexd/utils.py index fe01a86a..1c455fa5 100644 --- a/indexd/utils.py +++ b/indexd/utils.py @@ -32,13 +32,9 @@ def try_drop_test_data( # Using an engine that connects to the `postgres` database allows us to # create a new database. - engine = create_engine("postgresql://{user}@{host}/{name}".format( - user=root_user, host=host, name=database)) - - if sqlalchemy_utils.database_exists(engine.url): - sqlalchemy_utils.drop_database(engine.url) - - engine.dispose() + url = "postgresql://{user}@{host}/{name}".format(user=root_user, host=host, name=database) + if sqlalchemy_utils.database_exists(url): + sqlalchemy_utils.drop_database(url) def setup_database( @@ -51,11 +47,11 @@ def setup_database( # Create an engine connecting to the `postgres` database allows us to # create a new database from there. - engine = create_engine("postgresql://{user}@{host}/{name}".format( - user=root_user, host=host, name=database)) - if not sqlalchemy_utils.database_exists(engine.url): - sqlalchemy_utils.create_database(engine.url) + url = "postgresql://{user}@{host}/{name}".format(user=root_user, host=host, name=database) + if not sqlalchemy_utils.database_exists(url): + sqlalchemy_utils.create_database(url) + engine = create_engine(url) conn = engine.connect() if not no_user: