Skip to content

Commit

Permalink
only open one session
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdudfield committed Dec 1, 2023
1 parent 320194c commit bc4ef20
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pv_site_api/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@

from pvsite_datamodel.connection import DatabaseConnection

connection = DatabaseConnection(url=os.getenv("DB_URL", "not_set"))


def get_session():
"""Get database settion"""
if int(os.environ.get("FAKE", 0)):
yield None
else:
connection = DatabaseConnection(url=os.getenv("DB_URL", "not_set"))

with connection.get_session() as s:
yield s

0 comments on commit bc4ef20

Please sign in to comment.