From 601b7f499574538db7ad04005c302819e37ca3a7 Mon Sep 17 00:00:00 2001 From: Patrick Uiterwijk Date: May 22 2017 20:36:59 +0000 Subject: Make db_url optional Signed-off-by: Patrick Uiterwijk --- diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index 86d0847..9e4be8f 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -90,7 +90,7 @@ def get_user(session, key): SESSIONMAKER = None -def create_session(db_url, debug=False, pool_recycle=3600): +def create_session(db_url=None, debug=False, pool_recycle=3600): ''' Create the Session object to use to query the database. :arg db_url: URL used to connect to the database. The URL contains @@ -105,6 +105,8 @@ def create_session(db_url, debug=False, pool_recycle=3600): global SESSIONMAKER if SESSIONMAKER is None: + if db_url is None: + raise ValueError("First call to create_session needs db_url") if db_url.startswith('postgres'): # pragma: no cover engine = sqlalchemy.create_engine( db_url, echo=debug, pool_recycle=pool_recycle,