summaryrefslogtreecommitdiff
path: root/dev/engines/offline/sql-engines.html
blob: 240c930a992d347dbd2854c8a7d7f466bc9fde5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
<!DOCTYPE html>

<html lang="en" data-content_root="../../../">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>SQL Engines &#8212; SearXNG Documentation (2025.1.6+6dab7fe78)</title>
    <link rel="stylesheet" type="text/css" href="../../../_static/pygments.css?v=4f649999" />
    <link rel="stylesheet" type="text/css" href="../../../_static/searxng.css?v=52e4ff28" />
    <script src="../../../_static/documentation_options.js?v=ef740023"></script>
    <script src="../../../_static/doctools.js?v=9a2dae69"></script>
    <script src="../../../_static/sphinx_highlight.js?v=dc90522c"></script>
    <script data-project="searxng" data-version="2025.1.6+6dab7fe78" src="../../../_static/describe_version.js?v=fa7f30d0"></script>
    <link rel="index" title="Index" href="../../../genindex.html" />
    <link rel="search" title="Search" href="../../../search.html" />
    <link rel="next" title="Tineye" href="../online_url_search/tineye.html" />
    <link rel="prev" title="Local Search APIs" href="search-indexer-engines.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="Related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="../online_url_search/tineye.html" title="Tineye"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="search-indexer-engines.html" title="Local Search APIs"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../index.html">SearXNG Documentation (2025.1.6+6dab7fe78)</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../index.html" >Developer documentation</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../index.html" accesskey="U">Engine Implementations</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">SQL Engines</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="sql-engines">
<span id="id1"></span><h1>SQL Engines<a class="headerlink" href="#sql-engines" title="Link to this heading"></a></h1>
<aside class="sidebar">
<p class="sidebar-title">further read</p>
<ul class="simple">
<li><p><a class="reference external" href="https://www.sqlite.org/index.html">SQLite</a></p></li>
<li><p><a class="reference external" href="https://www.postgresql.org">PostgreSQL</a></p></li>
<li><p><a class="reference external" href="https://www.mysql.com">MySQL</a></p></li>
</ul>
</aside>
<nav class="contents local" id="contents">
<ul class="simple">
<li><p><a class="reference internal" href="#extra-dependencies" id="id11">Extra Dependencies</a></p></li>
<li><p><a class="reference internal" href="#configure-the-engines" id="id12">Configure the engines</a></p>
<ul>
<li><p><a class="reference internal" href="#engine-sqlite" id="id13">SQLite</a></p></li>
<li><p><a class="reference internal" href="#engine-postgresql" id="id14">PostgreSQL</a></p></li>
<li><p><a class="reference internal" href="#engine-mysql-server" id="id15">MySQL</a></p></li>
<li><p><a class="reference internal" href="#mariadb" id="id16">MariaDB</a></p></li>
</ul>
</li>
</ul>
</nav>
<aside class="sidebar">
<p class="sidebar-title">info</p>
<p>Initial sponsored by <a class="reference external" href="https://nlnet.nl/discovery">Search and Discovery Fund</a> of <a class="reference external" href="https://nlnet.nl/">NLnet Foundation</a>.</p>
</aside>
<p>With the <em>SQL engines</em> you can bind SQL databases into SearXNG.  The following
Relational Database Management System (RDBMS) are supported:</p>
<ul class="simple">
<li><p><a class="reference internal" href="#engine-sqlite"><span class="std std-ref">SQLite</span></a></p></li>
<li><p><a class="reference internal" href="#engine-postgresql"><span class="std std-ref">PostgreSQL</span></a></p></li>
<li><p><a class="reference internal" href="#engine-mysql-server"><span class="std std-ref">MySQL</span></a> &amp; <a class="reference internal" href="#engine-mariadb-server"><span class="std std-ref">MariaDB</span></a></p></li>
</ul>
<p>All of the engines above are just commented out in the <a class="extlink-origin reference external" href="https://github.com/searxng/searxng/blob/master/searx/settings.yml">settings.yml</a>, as you have to set the required attributes for the
engines, e.g. <code class="docutils literal notranslate"><span class="pre">database:</span></code></p>
<div class="highlight-yaml notranslate"><div class="highlight"><pre><span></span><span class="p p-Indicator">-</span><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">...</span>
<span class="w">  </span><span class="nt">engine</span><span class="p">:</span><span class="w"> </span><span class="p p-Indicator">{</span><span class="nv">sqlite|postgresql|mysql_server</span><span class="p p-Indicator">}</span>
<span class="w">  </span><span class="nt">database</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">...</span>
<span class="w">  </span><span class="nt">result_template</span><span class="p">:</span><span class="w"> </span><span class="p p-Indicator">{</span><span class="nv">template_name</span><span class="p p-Indicator">}</span>
<span class="w">  </span><span class="nt">query_str</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">...</span>
</pre></div>
</div>
<p>By default, the engines use the <code class="docutils literal notranslate"><span class="pre">key-value</span></code> template for displaying results /
see <a class="extlink-origin reference external" href="https://github.com/searxng/searxng/blob/master/searx/templates/simple/result_templates/key-value.html">simple</a>
theme.  If you are not satisfied with the original result layout, you can use
your own template, set <code class="docutils literal notranslate"><span class="pre">result_template</span></code> attribute to <code class="docutils literal notranslate"><span class="pre">{template_name}</span></code> and
place the templates at:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">searx</span><span class="o">/</span><span class="n">templates</span><span class="o">/</span><span class="p">{</span><span class="n">theme_name</span><span class="p">}</span><span class="o">/</span><span class="n">result_templates</span><span class="o">/</span><span class="p">{</span><span class="n">template_name</span><span class="p">}</span>
</pre></div>
</div>
<p>If you do not wish to expose these engines on a public instance, you can still
add them and limit the access by setting <code class="docutils literal notranslate"><span class="pre">tokens</span></code> as described in section
<a class="reference internal" href="../../../admin/settings/settings_engine.html#private-engines"><span class="std std-ref">Private Engines (tokens)</span></a>.</p>
<section id="extra-dependencies">
<h2><a class="toc-backref" href="#id11" role="doc-backlink">Extra Dependencies</a><a class="headerlink" href="#extra-dependencies" title="Link to this heading"></a></h2>
<p>For using <a class="reference internal" href="#engine-postgresql"><span class="std std-ref">PostgreSQL</span></a> or <a class="reference internal" href="#engine-mysql-server"><span class="std std-ref">MySQL</span></a> you need to
install additional packages in Python’s Virtual Environment of your SearXNG
instance.  To switch into the environment (<a class="reference internal" href="../../../admin/installation-searxng.html#searxng-src"><span class="std std-ref">Install SearXNG &amp; dependencies</span></a>) you can use
<a class="reference internal" href="../../../utils/searxng.sh.html#searxng-sh"><span class="std std-ref">utils/searxng.sh</span></a>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo utils/searxng.sh instance cmd bash
(searxng-pyenv)$ pip install ...
</pre></div>
</div>
</section>
<section id="configure-the-engines">
<h2><a class="toc-backref" href="#id12" role="doc-backlink">Configure the engines</a><a class="headerlink" href="#configure-the-engines" title="Link to this heading"></a></h2>
<p>The configuration of the new database engines are similar.  You must put a valid
SQL-SELECT query in <code class="docutils literal notranslate"><span class="pre">query_str</span></code>.  At the moment you can only bind at most one
parameter in your query.  By setting the attribute <code class="docutils literal notranslate"><span class="pre">limit</span></code> you can define how
many results you want from the SQL server.  Basically, it is the same as the
<code class="docutils literal notranslate"><span class="pre">LIMIT</span></code> keyword in SQL.</p>
<p>Please, do not include <code class="docutils literal notranslate"><span class="pre">LIMIT</span></code> or <code class="docutils literal notranslate"><span class="pre">OFFSET</span></code> in your SQL query as the engines
rely on these keywords during paging.  If you want to configure the number of
returned results use the option <code class="docutils literal notranslate"><span class="pre">limit</span></code>.</p>
<section id="engine-sqlite">
<span id="id2"></span><h3><a class="toc-backref" href="#id13" role="doc-backlink">SQLite</a><a class="headerlink" href="#engine-sqlite" title="Link to this heading"></a></h3>
<aside class="sidebar">
<p class="sidebar-title">info</p>
<ul class="simple">
<li><p><a class="extlink-origin reference external" href="https://github.com/searxng/searxng/blob/master/searx/engines/sqlite.py">sqlite.py</a></p></li>
</ul>
</aside>
<p id="module-searx.engines.sqlite">SQLite is a small, fast and reliable SQL database engine.  It does not require
any extra dependency.</p>
<section id="example">
<h4>Example<a class="headerlink" href="#example" title="Link to this heading"></a></h4>
<p>To demonstrate the power of database engines, here is a more complex example
which reads from a <a class="reference external" href="https://mediathekview.de/">MediathekView</a> (DE) movie database.  For this example of the
SQLite engine download the database:</p>
<ul class="simple">
<li><p><a class="reference external" href="https://liste.mediathekview.de/filmliste-v2.db.bz2">https://liste.mediathekview.de/filmliste-v2.db.bz2</a></p></li>
</ul>
<p>and unpack into <code class="docutils literal notranslate"><span class="pre">searx/data/filmliste-v2.db</span></code>.  To search the database use e.g
Query to test: <code class="docutils literal notranslate"><span class="pre">!mediathekview</span> <span class="pre">concert</span></code></p>
<div class="highlight-yaml notranslate"><div class="highlight"><pre><span></span><span class="p p-Indicator">-</span><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">mediathekview</span>
<span class="w">  </span><span class="nt">engine</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">sqlite</span>
<span class="w">  </span><span class="nt">disabled</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">False</span>
<span class="w">  </span><span class="nt">categories</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">general</span>
<span class="w">  </span><span class="nt">result_template</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">default.html</span>
<span class="w">  </span><span class="nt">database</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">searx/data/filmliste-v2.db</span>
<span class="w">  </span><span class="nt">query_str</span><span class="p">:</span><span class="w">  </span><span class="p p-Indicator">&gt;-</span>
<span class="w">    </span><span class="no">SELECT title || &#39; (&#39; || time(duration, &#39;unixepoch&#39;) || &#39;)&#39; AS title,</span>
<span class="w">           </span><span class="no">COALESCE( NULLIF(url_video_hd,&#39;&#39;), NULLIF(url_video_sd,&#39;&#39;), url_video) AS url,</span>
<span class="w">           </span><span class="no">description AS content</span>
<span class="w">      </span><span class="no">FROM film</span>
<span class="w">     </span><span class="no">WHERE title LIKE :wildcard OR description LIKE :wildcard</span>
<span class="w">     </span><span class="no">ORDER BY duration DESC</span>
</pre></div>
</div>
</section>
<section id="implementations">
<h4>Implementations<a class="headerlink" href="#implementations" title="Link to this heading"></a></h4>
</section>
<dl class="py function">
<dt class="sig sig-object py" id="searx.engines.sqlite.sqlite_cursor">
<span class="sig-prename descclassname"><span class="pre">searx.engines.sqlite.</span></span><span class="sig-name descname"><span class="pre">sqlite_cursor</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../../../_modules/searx/engines/sqlite.html#sqlite_cursor"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#searx.engines.sqlite.sqlite_cursor" title="Link to this definition"></a></dt>
<dd><p>Implements a <a class="reference external" href="https://docs.python.org/3/library/contextlib.html#contextlib.contextmanager" title="(in Python v3.13)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Context</span> <span class="pre">Manager</span></code></a> for a
<a class="reference external" href="https://docs.python.org/3/library/sqlite3.html#sqlite3.Cursor" title="(in Python v3.13)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sqlite3.Cursor</span></code></a>.</p>
<p>Open database in read only mode: if the database doesn’t exist.  The default
mode creates an empty file on the file system.  See:</p>
<ul class="simple">
<li><p><a class="reference external" href="https://docs.python.org/3/library/sqlite3.html#sqlite3.connect">https://docs.python.org/3/library/sqlite3.html#sqlite3.connect</a></p></li>
<li><p><a class="reference external" href="https://www.sqlite.org/uri.html">https://www.sqlite.org/uri.html</a></p></li>
</ul>
</dd></dl>

<dl class="py data">
<dt class="sig sig-object py" id="searx.engines.sqlite.database">
<span class="sig-prename descclassname"><span class="pre">searx.engines.sqlite.</span></span><span class="sig-name descname"><span class="pre">database</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">''</span></em><a class="headerlink" href="#searx.engines.sqlite.database" title="Link to this definition"></a></dt>
<dd><p>Filename of the SQLite DB.</p>
</dd></dl>

<dl class="py data">
<dt class="sig sig-object py" id="searx.engines.sqlite.query_str">
<span class="sig-prename descclassname"><span class="pre">searx.engines.sqlite.</span></span><span class="sig-name descname"><span class="pre">query_str</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">''</span></em><a class="headerlink" href="#searx.engines.sqlite.query_str" title="Link to this definition"></a></dt>
<dd><p>SQL query that returns the result items.</p>
</dd></dl>

</section>
<section id="engine-postgresql">
<span id="id3"></span><h3><a class="toc-backref" href="#id14" role="doc-backlink">PostgreSQL</a><a class="headerlink" href="#engine-postgresql" title="Link to this heading"></a></h3>
<aside class="sidebar">
<p class="sidebar-title">info</p>
<ul class="simple">
<li><p><a class="extlink-origin reference external" href="https://github.com/searxng/searxng/blob/master/searx/engines/postgresql.py">postgresql.py</a></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span></code> <a class="reference external" href="psycopg2">psycopg2-binary</a></p></li>
</ul>
</aside>
<p id="module-searx.engines.postgresql">PostgreSQL is a powerful and robust open source database.  Before configuring
the PostgreSQL engine, you must install the dependency <code class="docutils literal notranslate"><span class="pre">psychopg2</span></code>.</p>
<section id="id4">
<h4>Example<a class="headerlink" href="#id4" title="Link to this heading"></a></h4>
<p>Below is an example configuration:</p>
<div class="highlight-yaml notranslate"><div class="highlight"><pre><span></span><span class="p p-Indicator">-</span><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">my_database</span>
<span class="w">  </span><span class="nt">engine</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">postgresql</span>
<span class="w">  </span><span class="nt">database</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">my_database</span>
<span class="w">  </span><span class="nt">username</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">searxng</span>
<span class="w">  </span><span class="nt">password</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">password</span>
<span class="w">  </span><span class="nt">query_str</span><span class="p">:</span><span class="w"> </span><span class="s">&#39;SELECT</span><span class="nv"> </span><span class="s">*</span><span class="nv"> </span><span class="s">from</span><span class="nv"> </span><span class="s">my_table</span><span class="nv"> </span><span class="s">WHERE</span><span class="nv"> </span><span class="s">my_column</span><span class="nv"> </span><span class="s">=</span><span class="nv"> </span><span class="s">%(query)s&#39;</span>
</pre></div>
</div>
</section>
<section id="id5">
<h4>Implementations<a class="headerlink" href="#id5" title="Link to this heading"></a></h4>
</section>
<dl class="py data">
<dt class="sig sig-object py" id="searx.engines.postgresql.database">
<span class="sig-prename descclassname"><span class="pre">searx.engines.postgresql.</span></span><span class="sig-name descname"><span class="pre">database</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">''</span></em><a class="headerlink" href="#searx.engines.postgresql.database" title="Link to this definition"></a></dt>
<dd><p>Name of the database.</p>
</dd></dl>

<dl class="py data">
<dt class="sig sig-object py" id="searx.engines.postgresql.host">
<span class="sig-prename descclassname"><span class="pre">searx.engines.postgresql.</span></span><span class="sig-name descname"><span class="pre">host</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">'127.0.0.1'</span></em><a class="headerlink" href="#searx.engines.postgresql.host" title="Link to this definition"></a></dt>
<dd><p>Hostname of the DB connector</p>
</dd></dl>

<dl class="py data">
<dt class="sig sig-object py" id="searx.engines.postgresql.password">
<span class="sig-prename descclassname"><span class="pre">searx.engines.postgresql.</span></span><span class="sig-name descname"><span class="pre">password</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">''</span></em><a class="headerlink" href="#searx.engines.postgresql.password" title="Link to this definition"></a></dt>
<dd><p>Password for the DB connection.</p>
</dd></dl>

<dl class="py data">
<dt class="sig sig-object py" id="searx.engines.postgresql.port">
<span class="sig-prename descclassname"><span class="pre">searx.engines.postgresql.</span></span><span class="sig-name descname"><span class="pre">port</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">'5432'</span></em><a class="headerlink" href="#searx.engines.postgresql.port" title="Link to this definition"></a></dt>
<dd><p>Port of the DB connector</p>
</dd></dl>

<dl class="py data">
<dt class="sig sig-object py" id="searx.engines.postgresql.query_str">
<span class="sig-prename descclassname"><span class="pre">searx.engines.postgresql.</span></span><span class="sig-name descname"><span class="pre">query_str</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">''</span></em><a class="headerlink" href="#searx.engines.postgresql.query_str" title="Link to this definition"></a></dt>
<dd><p>SQL query that returns the result items.</p>
</dd></dl>

<dl class="py data">
<dt class="sig sig-object py" id="searx.engines.postgresql.username">
<span class="sig-prename descclassname"><span class="pre">searx.engines.postgresql.</span></span><span class="sig-name descname"><span class="pre">username</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">''</span></em><a class="headerlink" href="#searx.engines.postgresql.username" title="Link to this definition"></a></dt>
<dd><p>Username for the DB connection.</p>
</dd></dl>

</section>
<section id="engine-mysql-server">
<span id="id6"></span><h3><a class="toc-backref" href="#id15" role="doc-backlink">MySQL</a><a class="headerlink" href="#engine-mysql-server" title="Link to this heading"></a></h3>
<aside class="sidebar">
<p class="sidebar-title">info</p>
<ul class="simple">
<li><p><a class="extlink-origin reference external" href="https://github.com/searxng/searxng/blob/master/searx/engines/mysql_server.py">mysql_server.py</a></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span></code> <a class="extlink-pypi reference external" href="https://pypi.org/project/mysql-connector-python">mysql-connector-python</a></p></li>
</ul>
</aside>
<p id="module-searx.engines.mysql_server">MySQL is said to be the most popular open source database.  Before enabling
MySQL engine, you must install the package <code class="docutils literal notranslate"><span class="pre">mysql-connector-python</span></code>.</p>
<p>The authentication plugin is configurable by setting <code class="docutils literal notranslate"><span class="pre">auth_plugin</span></code> in the
attributes.  By default it is set to <code class="docutils literal notranslate"><span class="pre">caching_sha2_password</span></code>.</p>
<section id="id7">
<h4>Example<a class="headerlink" href="#id7" title="Link to this heading"></a></h4>
<p>This is an example configuration for querying a MySQL server:</p>
<div class="highlight-yaml notranslate"><div class="highlight"><pre><span></span><span class="p p-Indicator">-</span><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">my_database</span>
<span class="w">  </span><span class="nt">engine</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">mysql_server</span>
<span class="w">  </span><span class="nt">database</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">my_database</span>
<span class="w">  </span><span class="nt">username</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">searxng</span>
<span class="w">  </span><span class="nt">password</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">password</span>
<span class="w">  </span><span class="nt">limit</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">5</span>
<span class="w">  </span><span class="nt">query_str</span><span class="p">:</span><span class="w"> </span><span class="s">&#39;SELECT</span><span class="nv"> </span><span class="s">*</span><span class="nv"> </span><span class="s">from</span><span class="nv"> </span><span class="s">my_table</span><span class="nv"> </span><span class="s">WHERE</span><span class="nv"> </span><span class="s">my_column=%(query)s&#39;</span>
</pre></div>
</div>
</section>
<section id="id8">
<h4>Implementations<a class="headerlink" href="#id8" title="Link to this heading"></a></h4>
</section>
<dl class="py data">
<dt class="sig sig-object py" id="searx.engines.mysql_server.database">
<span class="sig-prename descclassname"><span class="pre">searx.engines.mysql_server.</span></span><span class="sig-name descname"><span class="pre">database</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">''</span></em><a class="headerlink" href="#searx.engines.mysql_server.database" title="Link to this definition"></a></dt>
<dd><p>Name of the database.</p>
</dd></dl>

<dl class="py data">
<dt class="sig sig-object py" id="searx.engines.mysql_server.host">
<span class="sig-prename descclassname"><span class="pre">searx.engines.mysql_server.</span></span><span class="sig-name descname"><span class="pre">host</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">'127.0.0.1'</span></em><a class="headerlink" href="#searx.engines.mysql_server.host" title="Link to this definition"></a></dt>
<dd><p>Hostname of the DB connector</p>
</dd></dl>

<dl class="py data">
<dt class="sig sig-object py" id="searx.engines.mysql_server.password">
<span class="sig-prename descclassname"><span class="pre">searx.engines.mysql_server.</span></span><span class="sig-name descname"><span class="pre">password</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">''</span></em><a class="headerlink" href="#searx.engines.mysql_server.password" title="Link to this definition"></a></dt>
<dd><p>Password for the DB connection.</p>
</dd></dl>

<dl class="py data">
<dt class="sig sig-object py" id="searx.engines.mysql_server.port">
<span class="sig-prename descclassname"><span class="pre">searx.engines.mysql_server.</span></span><span class="sig-name descname"><span class="pre">port</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">3306</span></em><a class="headerlink" href="#searx.engines.mysql_server.port" title="Link to this definition"></a></dt>
<dd><p>Port of the DB connector</p>
</dd></dl>

<dl class="py data">
<dt class="sig sig-object py" id="searx.engines.mysql_server.query_str">
<span class="sig-prename descclassname"><span class="pre">searx.engines.mysql_server.</span></span><span class="sig-name descname"><span class="pre">query_str</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">''</span></em><a class="headerlink" href="#searx.engines.mysql_server.query_str" title="Link to this definition"></a></dt>
<dd><p>SQL query that returns the result items.</p>
</dd></dl>

<dl class="py data">
<dt class="sig sig-object py" id="searx.engines.mysql_server.username">
<span class="sig-prename descclassname"><span class="pre">searx.engines.mysql_server.</span></span><span class="sig-name descname"><span class="pre">username</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">''</span></em><a class="headerlink" href="#searx.engines.mysql_server.username" title="Link to this definition"></a></dt>
<dd><p>Username for the DB connection.</p>
</dd></dl>

</section>
<section id="mariadb">
<span id="engine-mariadb-server"></span><h3><a class="toc-backref" href="#id16" role="doc-backlink">MariaDB</a><a class="headerlink" href="#mariadb" title="Link to this heading"></a></h3>
<aside class="sidebar">
<p class="sidebar-title">info</p>
<ul class="simple">
<li><p><a class="extlink-origin reference external" href="https://github.com/searxng/searxng/blob/master/searx/engines/mariadb_server.py">mariadb_server.py</a></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">pip</span> <span class="pre">install</span></code> <a class="extlink-pypi reference external" href="https://pypi.org/project/mariadb">mariadb</a></p></li>
</ul>
</aside>
<p id="module-searx.engines.mariadb_server">MariaDB is a community driven fork of MySQL. Before enabling MariaDB engine,
you must the install the pip package <code class="docutils literal notranslate"><span class="pre">mariadb</span></code> along with the necessary
prerequities.</p>
<p><a class="reference external" href="https://mariadb.com/docs/server/connect/programming-languages/c/install/">See the following documentation for more details</a></p>
<section id="id9">
<h4>Example<a class="headerlink" href="#id9" title="Link to this heading"></a></h4>
<p>This is an example configuration for querying a MariaDB server:</p>
<div class="highlight-yaml notranslate"><div class="highlight"><pre><span></span><span class="p p-Indicator">-</span><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">my_database</span>
<span class="w">  </span><span class="nt">engine</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">mariadb_server</span>
<span class="w">  </span><span class="nt">database</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">my_database</span>
<span class="w">  </span><span class="nt">username</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">searxng</span>
<span class="w">  </span><span class="nt">password</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">password</span>
<span class="w">  </span><span class="nt">limit</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">5</span>
<span class="w">  </span><span class="nt">query_str</span><span class="p">:</span><span class="w"> </span><span class="s">&#39;SELECT</span><span class="nv"> </span><span class="s">*</span><span class="nv"> </span><span class="s">from</span><span class="nv"> </span><span class="s">my_table</span><span class="nv"> </span><span class="s">WHERE</span><span class="nv"> </span><span class="s">my_column=%(query)s&#39;</span>
</pre></div>
</div>
</section>
<section id="id10">
<h4>Implementations<a class="headerlink" href="#id10" title="Link to this heading"></a></h4>
</section>
<dl class="py data">
<dt class="sig sig-object py" id="searx.engines.mariadb_server.database">
<span class="sig-prename descclassname"><span class="pre">searx.engines.mariadb_server.</span></span><span class="sig-name descname"><span class="pre">database</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">''</span></em><a class="headerlink" href="#searx.engines.mariadb_server.database" title="Link to this definition"></a></dt>
<dd><p>Name of the database.</p>
</dd></dl>

<dl class="py data">
<dt class="sig sig-object py" id="searx.engines.mariadb_server.host">
<span class="sig-prename descclassname"><span class="pre">searx.engines.mariadb_server.</span></span><span class="sig-name descname"><span class="pre">host</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">'127.0.0.1'</span></em><a class="headerlink" href="#searx.engines.mariadb_server.host" title="Link to this definition"></a></dt>
<dd><p>Hostname of the DB connector</p>
</dd></dl>

<dl class="py data">
<dt class="sig sig-object py" id="searx.engines.mariadb_server.password">
<span class="sig-prename descclassname"><span class="pre">searx.engines.mariadb_server.</span></span><span class="sig-name descname"><span class="pre">password</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">''</span></em><a class="headerlink" href="#searx.engines.mariadb_server.password" title="Link to this definition"></a></dt>
<dd><p>Password for the DB connection.</p>
</dd></dl>

<dl class="py data">
<dt class="sig sig-object py" id="searx.engines.mariadb_server.port">
<span class="sig-prename descclassname"><span class="pre">searx.engines.mariadb_server.</span></span><span class="sig-name descname"><span class="pre">port</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">3306</span></em><a class="headerlink" href="#searx.engines.mariadb_server.port" title="Link to this definition"></a></dt>
<dd><p>Port of the DB connector</p>
</dd></dl>

<dl class="py data">
<dt class="sig sig-object py" id="searx.engines.mariadb_server.query_str">
<span class="sig-prename descclassname"><span class="pre">searx.engines.mariadb_server.</span></span><span class="sig-name descname"><span class="pre">query_str</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">''</span></em><a class="headerlink" href="#searx.engines.mariadb_server.query_str" title="Link to this definition"></a></dt>
<dd><p>SQL query that returns the result items.</p>
</dd></dl>

<dl class="py data">
<dt class="sig sig-object py" id="searx.engines.mariadb_server.username">
<span class="sig-prename descclassname"><span class="pre">searx.engines.mariadb_server.</span></span><span class="sig-name descname"><span class="pre">username</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">''</span></em><a class="headerlink" href="#searx.engines.mariadb_server.username" title="Link to this definition"></a></dt>
<dd><p>Username for the DB connection.</p>
</dd></dl>

</section>
</section>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
  <span id="sidebar-top"></span>
      <div class="sphinxsidebar" role="navigation" aria-label="Main">
        <div class="sphinxsidebarwrapper">
  
    
            <p class="logo"><a href="../../../index.html">
              <img class="logo" src="../../../_static/searxng-wordmark.svg" alt="Logo of SearXNG"/>
            </a></p>
  

<h3><a href="../../../index.html">Table of Contents</a></h3>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../../user/index.html">User information</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../own-instance.html">Why use a private instance?</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../admin/index.html">Administrator documentation</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../../index.html">Developer documentation</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../../quickstart.html">Development Quickstart</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../rtm_asdf.html">Runtime Management</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../contribution_guide.html">How to contribute</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../index.html">Engine Implementations</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="../enginelib.html">Engine Library</a></li>
<li class="toctree-l3"><a class="reference internal" href="../engines.html">SearXNG’s engines loader</a></li>
<li class="toctree-l3"><a class="reference internal" href="../engine_overview.html">Engine Overview</a></li>
<li class="toctree-l3 current"><a class="reference internal" href="../index.html#engine-types">Engine Types</a><ul class="current">
<li class="toctree-l4"><a class="reference internal" href="../index.html#online-engines">Online Engines</a></li>
<li class="toctree-l4 current"><a class="reference internal" href="../index.html#offline-engines">Offline Engines</a><ul class="current">
<li class="toctree-l5"><a class="reference internal" href="../offline_concept.html">Offline Concept</a></li>
<li class="toctree-l5"><a class="reference internal" href="../demo/demo_offline.html">Demo Offline Engine</a></li>
<li class="toctree-l5"><a class="reference internal" href="command-line-engines.html">Command Line Engines</a></li>
<li class="toctree-l5"><a class="reference internal" href="nosql-engines.html">NoSQL databases</a></li>
<li class="toctree-l5"><a class="reference internal" href="search-indexer-engines.html">Local Search APIs</a></li>
<li class="toctree-l5 current"><a class="current reference internal" href="#">SQL Engines</a></li>
</ul>
</li>
<li class="toctree-l4"><a class="reference internal" href="../index.html#online-url-search">Online URL Search</a></li>
<li class="toctree-l4"><a class="reference internal" href="../index.html#online-currency">Online Currency</a></li>
<li class="toctree-l4"><a class="reference internal" href="../index.html#online-dictionary">Online Dictionary</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../search_api.html">Search API</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../plugins.html">Plugins</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../translation.html">Translation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../lxcdev.html">Developing in Linux Containers</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../makefile.html">Makefile &amp; <code class="docutils literal notranslate"><span class="pre">./manage</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="../../reST.html">reST primer</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../searxng_extra/index.html">Tooling box <code class="docutils literal notranslate"><span class="pre">searxng_extra</span></code></a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../../utils/index.html">DevOps tooling box</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../src/index.html">Source-Code</a></li>
</ul>

  <h3>Project Links</h3>
  <ul>
    <li><a href="https://github.com/searxng/searxng/tree/master">Source</a>
  
    <li><a href="https://github.com/searxng/searxng/wiki">Wiki</a>
  
    <li><a href="https://searx.space">Public instances</a>
  
    <li><a href="https://github.com/searxng/searxng/issues">Issue Tracker</a>
  </ul><h3>Navigation</h3>
<ul>
  <li><a href="../../../index.html">Overview</a>
    <ul>
      <li><a href="../../index.html">Developer documentation</a>
        <ul>
      <li><a href="../index.html">Engine Implementations</a>
        <ul>
          <li>Previous: <a href="search-indexer-engines.html" title="previous chapter">Local Search APIs</a>
          <li>Next: <a href="../online_url_search/tineye.html" title="next chapter">Tineye</a></ul>
      </li></ul>
      </li>
    </ul>
  </li>
</ul>
<search id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../../../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../../../_sources/dev/engines/offline/sql-engines.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="footer" role="contentinfo">
    &#169; Copyright SearXNG team.
    </div>
  </body>
</html>