@@ -0,0 +1,57 @@
1+# SPDX-License-Identifier: AGPL-3.0-or-later
3+ MySQL database (Offline)
9+engine_type = 'offline'
10+auth_plugin = 'caching_sha2_password'
18+result_template = 'key-value.html'
22+def init(engine_settings):
23+ if 'query_str' not in engine_settings:
24+ raise ValueError('query_str cannot be empty')
26+ if not engine_settings['query_str'].lower().startswith('select '):
27+ raise ValueError('only SELECT query is supported')
30+ _connection = mysql.connector.connect(
35+ auth_plugin=auth_plugin,
39+def search(query, params):
40+ query_params = {'query': query}
41+ query_to_run = query_str + ' LIMIT {0} OFFSET {1}'.format(limit, (params['pageno'] - 1) * limit)
43+ with _connection.cursor() as cur:
44+ cur.execute(query_to_run, query_params)
46+ return _fetch_results(cur)
49+def _fetch_results(cur):
52+ result = dict(zip(cur.column_names, map(str, res))),
53+ result['template'] = result_template
54+ results.append(result)