diff options
| author | Markus Heiser <markus.heiser@darmarit.de> | 2025-03-05 17:50:22 +0100 |
|---|---|---|
| committer | Markus Heiser <markus.heiser@darmarIT.de> | 2025-03-15 10:36:33 +0100 |
| commit | f49b2c94a9a9938133dbf94d686f00776ce96cdc (patch) | |
| tree | 7b74aa959100bd85054251221981039d185bc50e /searx/engines/postgresql.py | |
| parent | af5dbdf768d56d26669a54e532bef3238e3de2e4 (diff) | |
[mod] migrate all key-value.html templates to KeyValue type
The engines now all use KeyValue results and return the results in a
EngineResults object.
The sqlite engine can return MainResult results in addition to KeyValue
results (based on engine's config in settings.yml),
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/engines/postgresql.py')
| -rw-r--r-- | searx/engines/postgresql.py | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/searx/engines/postgresql.py b/searx/engines/postgresql.py index ddd0ef929..78af8783c 100644 --- a/searx/engines/postgresql.py +++ b/searx/engines/postgresql.py @@ -28,6 +28,8 @@ except ImportError: # manually to use the engine. pass +from searx.result_types import EngineResults + engine_type = 'offline' host = "127.0.0.1" @@ -50,7 +52,6 @@ query_str = "" limit = 10 paging = True -result_template = 'key-value.html' _connection = None @@ -72,7 +73,7 @@ def init(engine_settings): ) -def search(query, params): +def search(query, params) -> EngineResults: query_params = {'query': query} query_to_run = query_str + ' LIMIT {0} OFFSET {1}'.format(limit, (params['pageno'] - 1) * limit) @@ -82,20 +83,16 @@ def search(query, params): return _fetch_results(cur) -def _fetch_results(cur): - results = [] - titles = [] - +def _fetch_results(cur) -> EngineResults: + res = EngineResults() try: titles = [column_desc.name for column_desc in cur.description] - - for res in cur: - result = dict(zip(titles, map(str, res))) - result['template'] = result_template - results.append(result) + for row in cur: + kvmap = dict(zip(titles, map(str, row))) + res.add(res.types.KeyValue(kvmap=kvmap)) # no results to fetch except psycopg2.ProgrammingError: pass - return results + return res |