From 03f641b60088dfbbdf87b1189216c41aa6bd220b Mon Sep 17 00:00:00 2001 From: Thomas Lemoine Date: Tue, 22 Aug 2023 17:12:07 -0400 Subject: [PATCH] engine rename and autoflush inside session init for better type signatures --- align_data/db/session.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/align_data/db/session.py b/align_data/db/session.py index 65bf5de1..d9a9fb41 100644 --- a/align_data/db/session.py +++ b/align_data/db/session.py @@ -10,12 +10,13 @@ logger = logging.getLogger(__name__) -ENGINE = create_engine(DB_CONNECTION_URI, echo=False) +# We create a single engine for the entire application +engine = create_engine(DB_CONNECTION_URI, echo=False) @contextmanager def make_session(auto_commit=False): - with Session(ENGINE).no_autoflush as session: + with Session(engine, autoflush=False) as session: yield session if auto_commit: session.commit()