Skip to content

Commit

Permalink
addressing the None case
Browse files Browse the repository at this point in the history
  • Loading branch information
wbaccinelli committed Sep 22, 2023
1 parent fb6770c commit d6bd045
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions helper/helper_functions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import logging

import importlib_resources
import os
Expand Down Expand Up @@ -38,13 +39,19 @@ def init_engine():

return sessionmaker(bind=engine)
except:
logging.error('Connection to DB failed. Empty session maker')
return None


session_maker = init_engine()


def get_db_session():
global session_maker

if not session_maker:
session_maker = init_engine()

session = session_maker()

return session
Expand Down

0 comments on commit d6bd045

Please sign in to comment.