diff --git a/pillar_tool/db/migrations/env.py b/pillar_tool/db/migrations/env.py index 9a1312d..c07bbc5 100644 --- a/pillar_tool/db/migrations/env.py +++ b/pillar_tool/db/migrations/env.py @@ -1,3 +1,4 @@ +import os import tomllib from inspect import stack from logging.config import fileConfig @@ -30,6 +31,20 @@ target_metadata = Base.metadata # ... etc. def get_custom_url(): + # get the correct path + paths: list[str] = [ + "./pillar_tool.toml", + "/etc/pillar_tool/config.toml", + ] + selected_path = None + for path in paths: + if os.path.exists(path): + selected_path = path + break + + if selected_path is None: + raise RuntimeError("No loadable config found!") + with open("./pillar_tool.toml", 'rb') as f: data = tomllib.load(f) user = data['db']['user']