Skip to content

Instantly share code, notes, and snippets.

@4khil
Created September 27, 2022 18:52
Show Gist options
  • Save 4khil/2189d918f89beaad49ff0972bb631237 to your computer and use it in GitHub Desktop.
Save 4khil/2189d918f89beaad49ff0972bb631237 to your computer and use it in GitHub Desktop.
Upgrading sqlite3 in python [AmazonEC2/AmazonLinux2/Cloud9]
There are two SQLite instances, one is prepackaged with Python, the other of the machine/env.
Start with the following queries:
$ which sqlite3
/usr/bin/sqlite3
$ sqlite3 --version
3.7.x
The sqlite3 with your python is going to be similar.
Find python version :
$ python3
>> import sqlite3
>> sqlite3.sqlite_version
OR
python -c "import sqlite3; print(sqlite3.sqlite_version)"
Next, do these steps (few steps from here - https://stackoverflow.com/questions/57214850/trying-to-upgrade-sqlite-on-amazon-ec2, but not the same, doesn't work)
1.Download the latest source code with the configure script from here. Currently this is:
curl https://www.sqlite.org/2020/sqlite-autoconf-3320300.tar.gz | tar xzf -
2.Go into the created directory and create the Makefile with our system dependant options:
cd ./sqlite-autoconf-3320300 && ./configure
3.Build the binary
make
4.Install it
sudo make install
Now, you have created the sqlite3 file. You need to replace them everywhere you find the file sqlite3.
To find all these places - run the following command --
whereis sqlite3
sqlite3: /usr/bin/sqlite3 /usr/local/bin/sqlite3 /usr/include/sqlite3.h /opt/c9/bin/sqlite3 /usr/share/man/man1/sqlite3.1.gz
Now within this folder -- ./sqlite-autoconf-3320300 , find the sqlite3, sqlite3.h file and replace with the following cp command.
sudo cp sqlite-autoconf-3320300/sqlite3 /usr/local/bin/sqlite3
sudo cp sqlite-autoconf-3320300/sqlite3 /usr/local/bin/sqlite3
sudo cp sqlite-autoconf-3320300/sqlite3 /opt/c9/bin/sqlite3 {I am using c9, hence this file, figure out what file is in the opt/ dir)
sudo cp sqlite-autoconf-3320300/sqlite3.h /usr/include/sqlite3.h
Once done, you would have upgraded both env and python-env. Now you need to just define the path to it. For it, use the local/lib in usr.
export LD_LIBRARY_PATH="/usr/local/lib"
Now you should have this :
$ python -c "import sqlite3; print(sqlite3.sqlite_version)"
3.23.3
$ sqlite3 --version
3.32.3
Hope this fixes it for you! Took me almost 4 hours to figure this out while going through many failed SO, blogposts!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment