summaryrefslogtreecommitdiff
path: root/searx/engines/postgresql.py
diff options
context:
space:
mode:
Diffstat (limited to 'searx/engines/postgresql.py')
-rw-r--r--searx/engines/postgresql.py21
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