Skip to content

Commit

Permalink
Construcg DB URL from parts
Browse files Browse the repository at this point in the history
  • Loading branch information
womullan committed Mar 2, 2024
1 parent 961da5e commit b14ecf2
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions python/lsst/consdb/hinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b14ecf2

Please sign in to comment.