We need to use some of the newest sqlite feature like "UPDATE FROM", which is available from sqlite 3.33.0 (https://www.sqlite.org/changes.html).
In current debian docker image we use stable (buster) distribution, which has older version of sqlite lib (the name is libsqlite3-dev).
I compiled sqlite3 locally from sources in .sh script, but I’m not able to configure pythons sqlite3 module to use the just compiled version of sqlite.
This is how the code looks like:
# Download newer libsqlite3-dev with "UPDATE FROM" clause support
cd data_processing
wget "https://www.sqlite.org/2020/sqlite-amalgamation-3340000.zip" -O sqlite.zip
unzip sqlite.zip
rm sqlite.zip
mv sqlite-amalgamation-3340000 sqlite-3.34
cd sqlite-3.34
gcc shell.c sqlite3.c -lpthread -ldl -o sqlite3
# remove no longer needed file (everything else than just created sqlite3)
find . ! -name 'sqlite3' -type f -exec rm -f {} +
cd -
export PATH="$(pwd)/my_app/sqlite-3.34:$PATH"
Here we can see, that adding the binary to the path is not enough.
I also tried adding:
sys.path.insert(
0,
'/home/user/project/libs/my_app/sqlite-3.34'
)
into python code, no success.
Is there any way to configure sqlite3 python module to use a different sqlite lib installed on the system?
2
Answers
Use binary package of pysqlite3: https://github.com/coleifer/pysqlite3 in your requirements, add
in python code, use pysqlite3:
instead of sqlite3.
Alternative, as Anthony suggested: swapping the system binary You can swap the binary of the system:
And the you don't have to use
pysqlite3
in your code.to add to answer above (not enough rep)
to swap in the binary in-place of system sqlite3
credit: https://romandc.com/zappa-django-guide/walk_database/