summaryrefslogtreecommitdiff
path: root/searxng_extra
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarIT.de>2025-05-25 10:40:57 +0200
committerGitHub <noreply@github.com>2025-05-25 10:40:57 +0200
commit848c8d0544eb0138da4414a750f79b22883f91b2 (patch)
tree54a1ff72ef9e6d18bb6e5b5551edf6be2871e372 /searxng_extra
parente46187e3ce1fd118951c0e40eb8432af75acad7c (diff)
[mod] data: implement a simple currencies (SQL) database (#4836)
To reduce the memory footprint, this patch no longer loads the JSON data completely into memory. Instead, there is an SQL database based on `ExpireCacheSQLite`. The class CurrenciesDB is a simple DB application that encapsulates the DB (queries and initialization) and provides convenient methods like `name_to_iso4217` and `iso4217_to_name`. Related: - https://github.com/searxng/searxng/discussions/1892 - https://github.com/searxng/searxng/pull/3458#issuecomment-2900807671 - https://github.com/searxng/searxng/pull/4650 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searxng_extra')
-rwxr-xr-xsearxng_extra/update/update_currencies.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/searxng_extra/update/update_currencies.py b/searxng_extra/update/update_currencies.py
index 903bdcb44..288f0994e 100755
--- a/searxng_extra/update/update_currencies.py
+++ b/searxng_extra/update/update_currencies.py
@@ -15,9 +15,7 @@ import json
from searx.locales import LOCALE_NAMES, locales_initialize
from searx.engines import wikidata, set_loggers
-from searx.data import data_dir
-
-DATA_FILE = data_dir / 'currencies.json'
+from searx.data.currencies import CurrenciesDB
set_loggers(wikidata, 'wikidata')
locales_initialize()
@@ -149,7 +147,7 @@ def main():
if len(db['names'][name]) == 1:
db['names'][name] = db['names'][name][0]
- with DATA_FILE.open('w', encoding='utf8') as f:
+ with CurrenciesDB.json_file.open('w', encoding='utf8') as f:
json.dump(db, f, indent=4, sort_keys=True, ensure_ascii=False)