From bc4ef2050ad554475470a011d3bb3ad0ef56462e Mon Sep 17 00:00:00 2001 From: peterdudfield Date: Fri, 1 Dec 2023 13:07:25 +0000 Subject: [PATCH] only open one session --- pv_site_api/session.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pv_site_api/session.py b/pv_site_api/session.py index 9009b76..7d7e6f2 100644 --- a/pv_site_api/session.py +++ b/pv_site_api/session.py @@ -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 +