Upgrading SQLite on CentOS to 3.31.1 or Later

Upgrading SQLite on CentOS to 3.31.1 or Later

25 Jun 2020 6 min read

In case you work with stack Django plus python on centos server then you perhaps face the problem of Django ver. 2.2+ demands SQLite ver. 3.83+

Unfortunately, now there is the only ver. 3.7.17 in Centos repository. Because of that, you can’t update SQLite ver. using standard methods of Centos packages updating and downloading.

So there is no choice but to carry out the update manually. To make manual updating we need to carry on to operations

  1. Update SQLite ver.
  2. Recompile Python setup
RNDGen.com

Discover RNDGen

Unleash your development potential with powerful dummy data and password generator. Supercharge your workflow now!

Generate Data Now!

Step 1 – Updating SQLite ver. On CEntos server

At first find the necessary version for installation on the SQLite website, download section. And choose here the last version in the Source Code section.

SQLite-download-page

The latest version 3.31.1 (at the time of writing this article) you can find here https://www.sqlite.org/2020/sqlite-autoconf-3310100.tar.gz

If you want to use another version you can also download it at the direct URL with the mask described below.

source-code-repositories

The designation of the desired version can be found in the Timeline project. By searching for the word – Version.

https://www.sqlite.org/src/timeline

version-checking

When did you decide on the version of SQLite, connect to your Centos server via ssh with ROOT privileges or using SUDO User.

Switch to opt catalog

[root@server]# cd /opt

Upload there chosen SQLite ver.

[root@server]# wget
[root@server] tar -xzf sqlite-autoconf-3310100.tar.gz

Go to the unpacked directory with the source code

[root@server]# cd sqlite-autoconf-3310100

Configure source code

[root@server]# ./configure

Convert source code

[root@server]# make

Install new SQLite version

[root@server]# make install

Check SQLite version

[root@server]# sqlite3 --version 3.31.1 2020-01-27 19:55:54 
3bfa9cc97da10598521b342961df8f5f68c7388fa117345eeb516eaa837bb4d6

Next, checking the version of SQLite through Python, you will see that the version will be the previous one

[root@server]# python3
Python 3.7.2 (default, May 14 2020, 17:33:23) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>import sqlite3
>>> sqlite3.sqlite_version
'3.7.17'
>>>

For Python to see the new version of SQLite, recompile Python.

Step 2 – Recompiling Python to Use the New SQLite

SQLite is installed as a library and located along the path

/usr/local/lib

This is exactly what we want to do – we must use the library directory

/usr/local/lib

To do this, you must

specify a global variable LD_LIBRARY_PATH

To do this, add the following entry to the profile file

[root@server]# vim /etc/profile

And add an entry to the file

Set the library path

export LD_LIBRARY_PATH="/usr/local/lib
Export_LD_Library_Path

Note. Changing this file turned out to be a working solution for our server. Other sources indicate the need for this file change.

/root/.bashrc

then go to the Python folder

[root@server]# cd /opt/Python-x.y.z

It also can be at

/usr/src/Python-x.y.z

Configure Python

[root@server]# ./configure

Convert source code

[root@server]# make

Recompile python installation

[root@server]# make install

Checking the version of SQLite via Python

[root@server]# python3
Python 3.7.2 (default, May 14 2020, 17:33:23)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>import sqlite3
>>>sqlite3.sqlite_version
'3.31.1'
>>>

Note. To quickly check the version of SQLite without entering the python environment, you can use the following command

[root@server]# python3 -c "import sqlite3; print(sqlite3.sqlite_version)"
3.31.1

Hopefully, you handle it, and now your Python environment is using the correct SQLite version. If there are any questions, write them in comments, we’ll gladly answer all them promptly.

ERP development final cta

Get a Custom Solution with Web Design Sun

At Web Design Sun, we specialize in building web applications for clients in every business and industry.  If you’re interested in custom applications for your business, contact us today.

Contact us today to get started

More From Blog

Best AI Services for Generation Content

Artificial Intelligence (AI) has come a long way in recent years and has proven to be a valuable tool for content generation. With the help of AI, businesses and individuals can now generate high-quality content in a fraction of the time it would take to do it manually. In this blog post, we will take a look at some of the best AI services currently available for content generation and how they can help you save time and effort.
23 Jan 2023 11 min read

How To Merge Git branch To Master And Handle Merge Conflicts

How does Git decide which type of merge should be applied, and to handle with merge conflict that may occur in case of a 3-way merge?
30 Nov 2017 10 min read

How to Build Trust With Online Reviews

Are your online reviews helping or hurting your business? Discover how to make the power of customer ratings work for you.
27 Nov 2019 8 min read