Problem 1: Installed sqlite3 is too old.
We can capitalize on google deploying the latest Ubuntu LTS in codelab as shown below by accessing Ubuntu repositories. Dqlite team, funded by Canonical, maintains a ppa for dqlite which has a dependency for the latest stable sqlite3. We can upgrade sqlite3 with three lines.
!sudo add-apt-repository -y ppa:dqlite/stable
!sudo apt update
!sudo apt-get install -y sqlite3
Codelab environment
!lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.3 LTS
Release: 18.04
Codename: bionic
https://dqlite.io/docs/faq
https://launchpad.net/~dqlite/+archive/ubuntu/stable
Problem 2: Codelab has already loaded sqlite3 into memory
!lsof -p `ps -ef | grep ipykernel_launcher | head -n 1 | awk '{print $2}'` | grep sql
python3 131 root mem REG 7,0 2359698 /usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6 (path dev=0,46)
python3 131 root mem REG 7,0 5772741 /usr/lib/python3.6/lib-dynload/_sqlite3.cpython-36m-x86_64-linux-gnu.so (path dev=0,46)
As shown here, libsqlite3 is loaded into memory. Python3 interpreter will not be able use the newly installed sqlite3 unless the python process is restarted
Method 1: Kill the Python.
Crash the runtime kernel and juypter notebooks will restart it.
!sudo add-apt-repository -y ppa:dqlite/stable
!sudo apt update
!sudo apt-get install -y sqlite3
!sqlite3 --version
import sqlite3
print(sqlite3.sqlite_version_info)
###
!kill `ps -ef | grep ipykernel_launcher | head -n 1 | awk '{print $2}'; /usr/bin/python3 -m ipykernel_launcher -f /root/.local/share/jupyter/runtime/kernel-*.json`
###
import sqlite3
sqlite3.sqlite_version_info
Method 2: Exit the kernel - best solution
!sudo add-apt-repository -y ppa:dqlite/stable
!sudo apt update
!sudo apt-get install -y sqlite3
!sqlite3 --version
import sqlite3, os
print(sqlite3.sqlite_version_info)
os._exit(00)
import sqlite3
print(sqlite3.sqlite_version_info)
Restart ipython Kernel with a command from a cell