Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrading SQLite3 version used in python3 on linux?

I need to upgrade the sqlite3 version that my python 3 uses but there seems to be no clear answers and I don't understand what determines the version of sqlite3 used by python. I am running CentOS7 with python 3.6.4 installed. CentOS had sqlite version 3.7.17 installed and I upgraded this to 3.23.1 thinking python would also use this never version of sqlite.

import sqlite3
print(sqlite3.sqlite_version)

The following code still gives me 3.17. I have googled how to upgrade the version but most solutions seem to refer to pysqlite which is python 2 only. Other solutions talk about complicated compiling processes that go way over my head.

I don't understand what determines the sqlite version that python uses. Is it determined by the python version, OS installed sqlite version? I am also running python 3.6.4 on my windows PC and it says I am running 3.14.2 so it seems that the sqlite version does not depend on the python version.

What determines the sqlite version python uses? Is there not a more straight forward way to upgrade the sqlite version for python 3?

like image 300
Yano Avatar asked Apr 19 '18 11:04

Yano


2 Answers

sqlite3 is kind of external library. so, you need to set external library path.

try next command

printenv LD_LIBRARY_PATH

result will be empty, if you never set before.

next command will work using installed sqlite3 for python

export LD_LIBRARY_PATH="/usr/local/lib"

then, you can execute and get correct version you installed

import sqlite3
print(sqlite3.sqlite_version)

but this method will be reset when you logout and login again. so, if you want to do regist that environment variable every time you login, you should edit /etc/profile

sudo vi /etc/profile

and add export code

export LD_LIBRARY_PATH="/usr/local/lib"

then, if you log-out and log-in again, you can see LD_LIBRARY_PATH is registered.

like image 153
PYUNGHWA KIM Avatar answered Nov 09 '22 19:11

PYUNGHWA KIM


In Ubuntu, you can add dqlite repository and update it using apt.

sudo add-apt-repository -y ppa:dqlite/stable
sudo apt update
sudo apt install sqlite3
like image 21
korakot Avatar answered Nov 09 '22 21:11

korakot