aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-03-17 09:39:12 +0300
committerFrederick Muriuki Muriithi2022-03-17 09:39:12 +0300
commit19e1d5cbeb980566fef66f446411ced6c52fc446 (patch)
treed1664c15aea132861c1196c20a4b8d30a9692e42
parent9126eda6159c5d605c41aae276f5dd9ba8df3f01 (diff)
downloadgenenetwork2-19e1d5cbeb980566fef66f446411ced6c52fc446.tar.gz
Provide path to default settings/configuration file as a fallback
If the GN2_SETTINGS environment variable, is for some reason, not set, and the application actually ever tries to get a connection to the database, then use the default settings/configuration file.
-rw-r--r--wqflask/wqflask/database.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/wqflask/wqflask/database.py b/wqflask/wqflask/database.py
index 12115e5f..9f659ae6 100644
--- a/wqflask/wqflask/database.py
+++ b/wqflask/wqflask/database.py
@@ -22,7 +22,10 @@ def read_from_pyfile(pyfile, setting):
def sql_uri():
"""Read the SQL_URI from the environment or settings file."""
return os.environ.get(
- "SQL_URI", read_from_pyfile(os.environ.get("GN2_SETTINGS"), "SQL_URI"))
+ "SQL_URI", read_from_pyfile(
+ os.environ.get(
+ "GN2_SETTINGS", os.path.abspath("../etc/default_settings.py")),
+ "SQL_URI"))
engine = create_engine(sql_uri(), encoding="latin1")