-
Notifications
You must be signed in to change notification settings - Fork 2.3k
[mod] data: implement a simple currencies (SQL) database #4836
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
If I understand correctly the workflow is:
Why not store directly the SQLite files in the git repository, and then read directly these files:
To be able to read the automatic updates, the update scripts can write a .csv files in addition to the SQLite file. See #3458 for example implementation. This PR 3458 missed a check in production to make sure the memory footprint does not grow over time, then it went into limbo. |
👍 yes, this is the "current workflow".
Thinkable .. why not ..
On the long term I had a different solution in mind .. 🤔 .. the SQLite's
We need to versioning the DB schema ( OT but to give an example: I implemented similar for the SVG weather icons in PR #4663 (comment) ..
|
Look at #3458 which creates .csv files in addition to the .db files.
What are the benefits of a different repository? The data size is 8.6M, pretty much nothing if we look at the any web page.
Is there an urge to merge this PR? |
Above you asked ..
When we replace .json by .cvs .. what have we won? / except a csv diff is hard to read, compared to json file with sorted keys ..
The JSON files are dumps of databases; in my opinion, maintaining these databases shouldn't be part of the code. For example, take a look at the https://github.com/ClearURLs project, whose rules are also made available to the application via a database (a JSON dump https://github.com/ClearURLs/Rules ). By separating them, the database could be maintained independently of the code. But we don't have to separate it, if you prefer to maintain the DB (the JSON file) here in the code, then we'll leave it here (for now / we can decide it later).
As long we hold the DB here .. but when we separate DB from code, we need a versioning of the DB schema. |
Because this is simplest way to make a human readable SQL dump : mapping from one SQL row to one CSV line using But why not .json, however without foreign keys, everything is flatten to rows.
ClearURL is a browser extension where the users can pick different rules from different URLs. In addition, all SearXNG instances are going to ping one more URL when they starts.
I read again the messages, and feel sorry to insist: why we need to do that? Currently if we change the format of a data file, it's simple:
Everyone is going to pick the updates [1], no connectivity issue, no GH token, no CloudFlare protection, it's a simple life. Most probably I miss your point. |
... we can stick with the current procedure, which is the simplest solution for us developers, as you already said. As I already said, we can consider separation later if we ever have compelling reasons to do so. There's no need to decide that now.
A dump, yes, but the diff is hard to read, and a diff is what we have to read with every PR review. Anyway, I'd like to stick with JSON files for now... we can decide later whether it might be better to switch to a CVS file for one or another data source.
For most cases, that's sufficient, and the ExpireCache we currently have in our code is sufficient for that. Regarding external bangs, I need to reconsider whether we need a different DB schema than a simple key/value cache (a DB table with more than just one primary key)... but I can't judge that at this point... perhaps this data is unsuitable for a relational DB... we'll see. |
See #4093 (comment) Can we close this PR? |
No! ..why? and how is it related to a bug in the pipy engine .. I'm confused. More PRs will follow for the other data objects. This is just one to demonstrate. |
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: - searxng#1892 - searxng#3458 (comment) - searxng#4650 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
I need this patch for further development, since no technical defects could be found I will now merge this PR. |
Fix C&P typo from searxng#4836 Closes: searxng#4861
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: - searxng#1892 - searxng#3458 (comment) - searxng#4650 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Fix C&P typo from searxng#4836 Closes: searxng#4861
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_iso4217andiso4217_to_name.Related: