From f8a652affc7cc6e25ee49a163fe5e39480fcbbb6 Mon Sep 17 00:00:00 2001 From: Nicolas Palacio Date: Fri, 24 Jan 2025 11:30:40 +0100 Subject: [PATCH] Started implementing sqlalchemy Query class to manage the queries --- omnipath_server/service/_legacy.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/omnipath_server/service/_legacy.py b/omnipath_server/service/_legacy.py index 92b9f46..461719a 100644 --- a/omnipath_server/service/_legacy.py +++ b/omnipath_server/service/_legacy.py @@ -708,6 +708,7 @@ class LegacyService: def __init__( self, + con: _connection.Connection | dict | None = None, input_files = None, only_tables = None, exclude_tables = None, @@ -721,6 +722,8 @@ def __init__( _log('TableServer starting up.') + self.con = _connection.ensure_con(con) + self.input_files = copy.deepcopy(self.default_input_files) self.input_files.update(input_files or {}) self.data = {} @@ -1279,6 +1282,10 @@ def _query(self, args: dict, query_type: str) -> str: return bad_req + # Instance of sqlalchemy.orm.Query + query = self.con.session.query(self._schema(query_type)) + + #HERE if 'databases' in args: args['resources'] = args['databases'] @@ -1286,7 +1293,7 @@ def _query(self, args: dict, query_type: str) -> str: hdr = self._columns(query_type) # Filtering for resources - if b'resources' in req.args: + if 'resources' in args: resources = self._args_set(req, 'resources')