diff --git a/omnipath_metabo/schema/_connection.py b/omnipath_metabo/schema/_connection.py index 6a41ebb..b440f2b 100644 --- a/omnipath_metabo/schema/_connection.py +++ b/omnipath_metabo/schema/_connection.py @@ -1,4 +1,35 @@ + +import os +import yaml +from contextlib import closing + from sqlalchemy import create_engine class Connection: - def __init__(self, config_param, **kwargs ): \ No newline at end of file + def __init__( + self, + param: str | dict | None = None, + **kwargs + ): + + self._param = param or kwargs + self._parse_param() + + + def parse_param(self) -> None: + + self._from_file() + + + def _from_file(self) -> None: + + if isinstance(self._param, str) and os.path.exists(self._param): + + self._param = yaml.load( + closing(open(self._param, 'r')), + Loader = yaml.FullLoader, + ) + + def _uri(self) -> str: + + return f'postgresql://'