Skip to content

Commit

Permalink
engine rename and autoflush inside session init for better type signa…
Browse files Browse the repository at this point in the history
…tures
  • Loading branch information
Thomas-Lemoine committed Aug 22, 2023
1 parent 513b87a commit 03f641b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions align_data/db/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 03f641b

Please sign in to comment.