[FarGroup/FarManager] master: Add sqlite update script (fa95dc0b9)

0 views
Skip to first unread message

farg...@farmanager.com

unread,
Apr 11, 2026, 6:30:56 AM (5 days ago) Apr 11
to farco...@googlegroups.com
Repository : https://github.com/FarGroup/FarManager
On branch : master
Link : https://github.com/FarGroup/FarManager/commit/fa95dc0b9d42283a2ae6b732f634b09eafe23bfd

>---------------------------------------------------------------

commit fa95dc0b9d42283a2ae6b732f634b09eafe23bfd
Author: Alex Alabuzhev <alab...@gmail.com>
Date: Sat Apr 11 11:26:47 2026 +0100

Add sqlite update script


>---------------------------------------------------------------

fa95dc0b9d42283a2ae6b732f634b09eafe23bfd
far/thirdparty/sqlite/update.py | 67 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)

diff --git a/far/thirdparty/sqlite/update.py b/far/thirdparty/sqlite/update.py
new file mode 100644
index 000000000..2d6067ba3
--- /dev/null
+++ b/far/thirdparty/sqlite/update.py
@@ -0,0 +1,67 @@
+import csv
+import io
+import os.path
+import re
+import urllib.request
+import zipfile
+
+BASE_URL = "https://sqlite.org/"
+
+def fetch_url(url):
+ with urllib.request.urlopen(url) as response:
+ return response.read()
+
+
+def extract_csv_from_html(html):
+ pattern = re.compile(r"<!--\s*Download product data for scripts to read\s*(.*?)-->", re.DOTALL)
+ match = pattern.search(html)
+ if not match:
+ raise RuntimeError("CSV data block not found in HTML")
+
+ return match.group(1).strip()
+
+
+def main():
+ print("Fetching download page")
+ html_bytes = fetch_url(f"{BASE_URL}download.html")
+ html = html_bytes.decode()
+
+ print("Extracting CSV data from HTML comment")
+ csv_text = extract_csv_from_html(html)
+
+ reader = csv.DictReader(csv_text.splitlines())
+
+ print("Searching for sqlite-amalgamation ZIP")
+ selected = None
+
+ for row in reader:
+ rel_url = row["RELATIVE-URL"]
+ if "sqlite-amalgamation" in rel_url and rel_url.endswith(".zip"):
+ selected = row
+ break
+
+ if not selected:
+ raise RuntimeError("No sqlite-amalgamation ZIP found")
+
+ zip_url = BASE_URL + selected["RELATIVE-URL"]
+ print(f"Found ZIP")
+ print(f" URL: {zip_url}")
+ print(f" Version: {selected['VERSION']}")
+ print(f" Size: {selected['SIZE-IN-BYTES']} bytes")
+
+ print("Downloading ZIP file")
+ zip_bytes = fetch_url(zip_url)
+
+ print("Extracting ZIP")
+ with zipfile.ZipFile(io.BytesIO(zip_bytes)) as zf:
+ root = zf.namelist()[0]
+ for name in ("sqlite3.c", "sqlite3.h"):
+ print(f"Extracting {name}")
+ with zf.open(root + name) as src, open(name, "wb") as dst:
+ dst.write(src.read())
+
+ print("Done")
+
+
+if __name__ == "__main__":
+ main()


Reply all
Reply to author
Forward
0 new messages