From b14ecf24a701a98f914b50568f3e1c87f0850351 Mon Sep 17 00:00:00 2001 From: William O'Mullane Date: Sat, 2 Mar 2024 16:53:20 -0300 Subject: [PATCH] Construcg DB URL from parts --- python/lsst/consdb/hinfo.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/python/lsst/consdb/hinfo.py b/python/lsst/consdb/hinfo.py index 2687c3a7..7c7891cc 100644 --- a/python/lsst/consdb/hinfo.py +++ b/python/lsst/consdb/hinfo.py @@ -251,9 +251,17 @@ def process_date(day_obs: str) -> None: translator = LsstCamTranslator instrument_mapping = LSSTCAM_MAPPING -url = os.environ.get( - "POSTGRES_URL", "postgresql://usdf-butler.slac.stanford.edu:5432/lsstdb1" -) +host = os.environ.get("DB_HOST") +passwd = os.environ.get("DB_PASS") +user = os.environ.get("DB_USER") +dbname = os.environ.get("DB_NAME") +url = "" +if host and passwd and user and dbname: + url = f"postgresql://{user}:{passwd}@{host}/{dbname}" +else: + url = os.environ.get( + "POSTGRES_URL", "postgresql://usdf-butler.slac.stanford.edu:5432/lsstdb1" + ) engine = create_engine(url) metadata_obj = MetaData(schema=f"cdb_{instrument.lower()}") exposure_table = Table("exposure", metadata_obj, autoload_with=engine)