Hacker News new | ask | show | jobs
by simonw 882 days ago
If anyone wants to try this out on macOS here's the fastest way I've found to try a new SQLite version there: https://til.simonwillison.net/sqlite/sqlite-version-macos-py...

Short version:

    cd /tmp
    wget 'https://www.sqlite.org/2024/sqlite-amalgamation-3450000.zip'
    unzip sqlite-amalgamation-3450000.zip
    cd sqlite-amalgamation-3450000
    gcc -dynamiclib sqlite3.c -o libsqlite3.0.dylib -lm -lpthread
    DYLD_LIBRARY_PATH=$PWD python3 -c "import sqlite3; print(sqlite3.sqlite_version)"
That prints "3.45.0" for me.

If you have https://datasette.io/ installed you can then get a web UI for trying it out by running:

    DYLD_LIBRARY_PATH=$PWD datasette
4 comments

> If anyone wants to try this out on macOS here's the fastest way I've found to try a new SQLite version ...

https://sqlite.org/fiddle

is always updated as part of the release process and is updated periodically between releases.

FWIW, this works for me with Python 3.12 from Homebrew, but not Python 3.12 from python.org. _sqlite3.cpython-312-darwin.so in Homebrew's Python appears to dynamically link /opt/homebrew/opt/sqlite/lib/libsqlite3.0.dylib, but the version in python.org's Python statically links the sqlite3 library.

EDIT: Python 3.9.6 from Xcode doesn't work either. It has _sqlite3.cpython-39-darwin.so which dynamically links /usr/lib/libsqlite3.dylib, but that dylib doesn't exist on my system, and I don't know enough about macOS internals to tell where it's coming from. The _sqlite3 so doesn't seem big enough to have it statically linked.

EDIT2: Xcode's Python works when launching via the real path instead of using the /usr/bin/python3 alias, I assume because /usr/bin is SIP-protected or something.

Thanks for that, I'll add a note to my TIL.
If you change the version, URL, and the sha256 in conda-forge/sqlite-feedstock//recipe/meta.yaml and send a PR, it should build end then deploy the latest version so that you can just `mamba install -y sqlite libspatiallite sqlite-utils` without also mamba installing gcc or clang. https://github.com/conda-forge/sqlite-feedstock/blob/main/re... https://github.com/conda-forge/sqlite-feedstock/blob/main/re...
and the easiest way for those who can wait for the next update will be to get the binaries from https://cosmo.zip/pub/cosmos/bin/datasette and https://cosmo.zip/pub/cosmos/bin/sqlite3