-
-
Notifications
You must be signed in to change notification settings - Fork 699
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
What minimal SQLite version should Datasette support? #2349
Comments
Had a great suggestion here: https://chaos.social/@djh/112594380456382194
Also: https://hachyderm.io/@zack/112594435807681224
|
The biggest question to answer here is if there are any widely used distros that we need to support - like Red Hat Enterprise Linux - which ship with an older version of SQLite but still include a supported version of Python. |
Decision: we're going to go with the first release that added window functions, and tell anyone with older versions to use 3.25 (2018-09-15) With the JSON extension enabled (it's enabled by default from 2022-02-22 (3.38.0)) |
Automated tests: let's test Mac an Ubuntu against all supported Python's against SQLite minimum version AND SQLite latest version. |
Our earliest supported version can be downloaded from https://www.sqlite.org/2018/sqlite-amalgamation-3250300.zip |
Following https://til.simonwillison.net/sqlite/sqlite-version-macos-python Built the macOS cd /tmp
wget 'https://www.sqlite.org/2018/sqlite-amalgamation-3250300.zip'
unzip sqlite-amalgamation-3250300.zip
cd sqlite-amalgamation-3250300
gcc -dynamiclib sqlite3.c -o libsqlite3.0.dylib -lm -lpthread \
-DSQLITE_ENABLE_FTS3 \
-DSQLITE_ENABLE_FTS3_PARENTHESIS \
-DSQLITE_ENABLE_FTS4 \
-DSQLITE_ENABLE_FTS5 \
-DSQLITE_ENABLE_JSON1 \
-DSQLITE_ENABLE_RTREE Then run Datasette against it like this: DYLD_LIBRARY_PATH=/tmp/sqlite-amalgamation-3250300 datasette --get /-/versions.json | jq And got: {
"python": {
"version": "3.10.14",
"full": "3.10.14 (main, Mar 19 2024, 21:46:16) [Clang 15.0.0 (clang-1500.3.9.4)]"
},
"datasette": {
"version": "1.0a13"
},
"asgi": "3.0",
"uvicorn": "0.20.0",
"sqlite": {
"version": "3.25.3",
"fts_versions": [
"FTS5",
"FTS4",
"FTS3"
],
"extensions": {
"json1": null
},
"compile_options": [
"COMPILER=clang-15.0.0",
"ENABLE_FTS3",
"ENABLE_FTS3_PARENTHESIS",
"ENABLE_FTS4",
"ENABLE_FTS5",
"ENABLE_JSON1",
"ENABLE_RTREE",
"THREADSAFE=1"
]
}
} |
Here's the recipe to get that version of SQLite with Python in an Ubuntu Docker container. First save this as #!/bin/bash
export DEBIAN_FRONTEND=noninteractive
apt-get update && apt-get install -y python-is-python3 wget build-essential unzip
wget https://www.sqlite.org/2018/sqlite-amalgamation-3250300.zip
unzip sqlite-amalgamation-3250300.zip
cd sqlite-amalgamation-3250300
gcc -fPIC -shared -o libsqlite3.so sqlite3.c -lm -lpthread \
-DSQLITE_ENABLE_FTS3 \
-DSQLITE_ENABLE_FTS3_PARENTHESIS \
-DSQLITE_ENABLE_FTS4 \
-DSQLITE_ENABLE_FTS5 \
-DSQLITE_ENABLE_JSON1 \
-DSQLITE_ENABLE_RTREE
python -c 'import sqlite3; print(
sqlite3.connect(":memory:").execute("select sqlite_version()").fetchall()
)' Then run this (for an Apple Silicon device, hence the docker run --rm -it --platform linux/arm64/v8 -v $(pwd)/script.sh:/script.sh ubuntu bash -c 'chmod +x /script.sh && /script.sh; exec bash' This drops into an interactive shell after the software has been installed. I see this:
It can take a few minutes though, so would be good to optimize this. |
Then in the shell I need to do this:
|
Then to run the Datasette tests against that SQLite version inside the container: apt-get install -y python3-pip git python3.12-venv
git clone https://github.com/simonw/datasette
cd datasette/
python -m venv venv
source venv/bin/activate
pip install -e '.[test]'
LD_PRELOAD=/sqlite-amalgamation-3250300/libsqlite3.so pytest tests/test_api_write.py Annoyingly the tests pass for me - refs #2356
|
Datasette core's SQLite usage is pretty tame:
CREATE TABLE
, simple selects, update/insert, etc. I don't think we need to use a lot of fancy new SQLite features. Except maybe UPSERt.SQLite release history: https://www.sqlite.org/changes.html
Scrolling through and thinking about all the SQLite-related version bugs, the only thing I can think of is not having UPSERTs in older SQLite versions.
Security?
Could we say "SQLite version's below 3.XX have security issues so you must upgrade"? https://www.sqlite.org/cves.html
The only "real" recent SQLite CVE is maybe from 3.39.2 with a buffer overflow, but that's a C API thing and not exploitable by Datasette afaik
The text was updated successfully, but these errors were encountered: