63def init(engine_settings):
64 global _connection # pylint: disable=global-statement
66 if 'query_str' not in engine_settings:
67 raise ValueError('query_str cannot be empty')
69 if not engine_settings['query_str'].lower().startswith('select '):
70 raise ValueError('only SELECT query is supported')
72 _connection = mysql.connector.connect(
78 auth_plugin=auth_plugin,
82def search(query, params) -> EngineResults:
84 query_params = {'query': query}
85 query_to_run = query_str + ' LIMIT {0} OFFSET {1}'.format(limit, (params['pageno'] - 1) * limit)
87 with _connection.cursor() as cur:
88 cur.execute(query_to_run, query_params)
90 kvmap = dict(zip(cur.column_names, map(str, row)))
91 res.add(res.types.KeyValue(kvmap=kvmap))