Skip to content

Commit

Permalink
Connection: process pgsql connection param
Browse files Browse the repository at this point in the history
  • Loading branch information
deeenes committed Sep 18, 2024
1 parent 045e97e commit 6ac1009
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion omnipath_metabo/schema/_connection.py
Original file line number Diff line number Diff line change
@@ -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 ):
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://'

0 comments on commit 6ac1009

Please sign in to comment.