Prefer environment variables to connect to DB

This commit is contained in:
D. Berge
2020-08-12 14:38:31 +02:00
parent 8ea220d09e
commit b1a088da36

View File

@@ -17,7 +17,14 @@ def read (file = None):
if file is None: if file is None:
file = prefix+"/etc/config.yaml" file = prefix+"/etc/config.yaml"
with open(file, "r") as fd: with open(file, "r") as fd:
return _load(fd) cfg = _load(fd)
if "db" in cfg and "connection_string" in cfg["db"] and os.environ.get("PGDATABASE"):
# This should cause the PostgreSQL library to use the environment variables
cfg["db"]["connection_string"] = ""
print("Using environment variables for database connection")
return cfg
def files (globspec = None, include_archived = False): def files (globspec = None, include_archived = False):
""" """