diff options
| author | Alexandre Flament <alex@al-f.net> | 2021-12-27 19:11:01 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-27 19:11:01 +0100 |
| commit | c6922ae7c5e53f695d5f5f8704b10b4e2815cda4 (patch) | |
| tree | 9c0456ad1a1d9d375311ccd8c9bd3eafd0779114 /searx/engines/postgresql.py | |
| parent | 54bce130f9074c3d63009237b014c727a1443cc5 (diff) | |
| parent | d84226bf63757b1d4245ab26e9c081daf42389aa (diff) | |
Merge pull request #619 from dalf/apply-black
Apply black
Diffstat (limited to 'searx/engines/postgresql.py')
| -rw-r--r-- | searx/engines/postgresql.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/searx/engines/postgresql.py b/searx/engines/postgresql.py index 1eddcd519..d8bbabe27 100644 --- a/searx/engines/postgresql.py +++ b/searx/engines/postgresql.py @@ -20,6 +20,7 @@ paging = True result_template = 'key-value.html' _connection = None + def init(engine_settings): global _connection # pylint: disable=global-statement @@ -30,25 +31,24 @@ def init(engine_settings): raise ValueError('only SELECT query is supported') _connection = psycopg2.connect( - database = database, - user = username, - password = password, - host = host, - port = port, + database=database, + user=username, + password=password, + host=host, + port=port, ) + def search(query, params): query_params = {'query': query} - query_to_run = ( - query_str - + ' LIMIT {0} OFFSET {1}'.format(limit, (params['pageno'] - 1) * limit) - ) + query_to_run = query_str + ' LIMIT {0} OFFSET {1}'.format(limit, (params['pageno'] - 1) * limit) with _connection: with _connection.cursor() as cur: cur.execute(query_to_run, query_params) return _fetch_results(cur) + def _fetch_results(cur): results = [] titles = [] |