Skip to content

Commit

Permalink
changed the session maker to reuse engines
Browse files Browse the repository at this point in the history
  • Loading branch information
henri123lemoine committed Aug 18, 2023
1 parent 8ac789f commit b5c0457
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,11 +10,12 @@

logger = logging.getLogger(__name__)

ENGINE = create_engine(DB_CONNECTION_URI, echo=False)


@contextmanager
def make_session(auto_commit=False):
engine = create_engine(DB_CONNECTION_URI, echo=False)
with Session(engine).no_autoflush as session:
with Session(ENGINE).no_autoflush as session:
yield session
if auto_commit:
session.commit()
Expand Down

0 comments on commit b5c0457

Please sign in to comment.