Debian

How to Install SQLite on Debian 11

SQLite is one of the Relational C-library DBMS(Database Management System). SQLite is not a client-server Database Engine as opposed to several other Database Management Systems. SQLite is a common pick in application software, such as web browsers,as a local/client storage integrated Database System. It is probably the most frequently used database engine because it is used by many widely known browsers, Operating Systems, mobile applications and embedded systems today. SQLite records the whole database on a host system as a single platform file.

File-based is SQLite. It is not the same as other SQL Databases because SQLite has no separate server process, as is the case with most other SQL databases. Installation process of SQLite on Debian 11(Linux OS) by Two methods is explained in the Article:

  • How to install SQLite from Debian Repository
  • How to Install SQLite using SQLite website

Before installation of SQLite from any of the one method update the packages:

Updating Packages

It is important to ensure your system is up-to-date before installation of any software by running the below mentioned command:

$ sudo apt update

Now to get latest version of all installed packages on your system, upgrade your packages by running below mentioned command:

$ sudo apt upgrade

Now all my packages are updated and upgraded.

Method 1: How to install SQLite from Debian Repository

As SQLite is already present in the Debian 11 repository, we can easily install the SQLite from the repository but that is not the latest version of SQLite.

Step1:  Installing SQLite on Debian 11

Run the below mentioned command to install the available version of SQLite from Debian 11 repository:

$ sudo apt install sqlite3

Step2: Checking Version

To verify the installation, check version number of SQLite by below mentioned command:

$ sqlite3 --version

Method 2:  How to Install SQLite using SQLite website

The latest stable version of SQLite at the time of writing this article is “3.36.0” but unfortunately in Debian 11 repository, the latest version is not available. So to install the latest version directly from SQLite web page we will use wget and tar command.

Follow the steps below to successfully install the latest version:

Step 1: Installing build tools

First we need to install the build tools for construction of package, run the below mentioned command to install “build-essentials”:

$ sudo apt install build-essential


Step2: Getting SQLite Source code

To install SQLite source code, go to SQLite website, check for the latest version or any version you want to install and copy its source code link; in my case the latest is 3.36.0. Now download it using below mentioned command:

wget –c https://www.sqlite.org/2021/sqlite-autoconf-3360000.tar.gz

You can replace SQLite source code link if you are installing some other version in wget command.

Step3:  Extracting the Source code

Run the below mentioned command to create a separate directory to extract the source code in that folder:

$ mkdir SQLite

You can set the name of directory according to your choice:

Now move to newly created directory by below mentioned command:

$ cd SQLite


Now extract the source code of SQLite by tar command:

$ tar xvfz ../sqlite-autoconf-3360000.tar.gz


Step4: Compiling Source code of SQLite

To compile extracted source code first you need to get access to generated folder by below mentioned command:

$ cd sqlite-autoconf-3360000/


To start compiling, configure the code by below mentioned command:

$ ./configure


Now use the make command to build libraries and executable files from source code of SQLite:

$ make

Step5: Installing SQLite

Now install the sqlite 3.36.0 version with the help of the make command by running below mentioned command:

$ sudo make install

Step6: Verifying Installation

To verify the installation of latest version of SQLite, check the version number by below mentioned command:

$ sqlite3 --version

How to test SQLite

After successful installation of SQLite, you can create a database and table to test its working.

Create Database “linuxhint.db” with help of sqlite3 command as mentioned below:

$ sqlite3 linuxhint.db


Now create the table “linux” with parameters (name String,version INT) by below mentioned code:

CREATE TABLE linux(name String,version INT);


Insert data in to newly created table:

INSERT INTO linux VALUES(“Debian”,11),(“Ubuntu”,21);


Now get data from “linux” table by below mentioned query:

SELECT * FROM linux;


You can write more queries according to your requirement; this was just a sample to show you how SQLite works in Debian 11 terminal.

Conclusion:

SQLite is a file-based relational Database, it contains C-library. It is a commonly used Database Engine mostly used in mobile applications. It records the whole Database on a host system as a single platform file. In this article we have discussed the installation of SQLite on Debian 11 by two methods; from Debian 11 repository and by SQLite website using wget command. Also the working of SQLite using sqlite3 command on terminal is discussed. After reading this article you will be able to successfully install and use SQLite on your Debian 11 system.

About the author

Alishba Iftikhar

I am currently an undergraduate student in my 1st year. I am an internee author with Linuxhint and loved learning the art of technical content writing from senior authors. I am looking forward to opting my career as a full time Linux writer after I graduate.