(This article applies to Debian-based Linux, such as Ubuntu, Raspbian, and so on.) )
On Linux, Python's sqlite3 module uses the system's own SQLite engine , but the system comes with a version of SQLite that is too old.
Look at the version of the SQLite engine with sqlite3.sqlite_version, and find out that this version was released in June 2012:
To upgrade the SQLite engine to a new version and be used by Python, the following two steps are required:
1, first download, compile, install SQLite engine
To the website of sqlite download page: https://www.sqlite.org/download.html Here is the latest version, we will install it.
Source code has two files, we next second (sqlite-autoconf-3160200.tar.gz), because this has a configuration file. Copy its link, and then execute it at the terminal:
wget https:// www.sqlite.org/2017/sqlite-autoconf-3160200.tar.gz Tar ZXVF Sqlite-autoconf-3160200.tar . GZ sqlite-autoconf-3160200./configuremakesudo make Install
When installed by default, the compiled binaries are installed to/usr/local/lib, the head file Sqlite3.h sqlite3ext.h installed to/usr/local/include, and we need to know both paths.
2. Download, compile, install Python
Please do it according to this article: http://www.cnblogs.com/infopi/p/update_python_raspbian.html
The only difference is that it is slightly different at compile time. Let's say we're installing Python 3.5:
CD./python-3.5.3./configure--prefix=/opt/python3.5makemakesudo make Install
To change to:
CD./python-3.5.3ld_run_path=/usr/local/lib --prefix=/opt/python3.5ld_run_path=/usr/local/ Lib makemakesudo make install
The blue word is more than the above, indicating that Python will go to those two directories to find SQLite.
After this installation, you can already use the latest version of SQLite, which was released in January 2017:
This article refers to the method on the StackOverflow, to express appreciation ~
In case, the method of this article does not work, can sudo apt-get remove sqlite3 libsqlite3-dev, and then try again.
Upgrade SQLite on Ubuntu and let Python use the new version of SQLite