aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/database.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/wqflask/wqflask/database.py b/wqflask/wqflask/database.py
index 4b05c926..82a35013 100644
--- a/wqflask/wqflask/database.py
+++ b/wqflask/wqflask/database.py
@@ -10,6 +10,14 @@ import contextlib
import MySQLdb
+def read_from_pyfile(pyfile, setting):
+ orig_sys_path = sys.path[:]
+ sys.path.insert(0, os.path.dirname(pyfile))
+ module = importlib.import_module(os.path.basename(pyfile).strip(".py"))
+ sys.path = orig_sys_path[:]
+ return module.__dict__.get(setting)
+
+
def sql_uri():
"""Read the SQL_URI from the environment or settings file."""
return os.environ.get(