How to install SQLite on Debian 11

SQLite is one of the relational DBMS C-library (database management system). SQLite is not a client-server database engine like several other database management systems. SQLite is often used in application software such as web browsers as an integrated database system for local / client storage. It is probably the most commonly used database engine as it is used by many well-known browsers, operating systems, mobile applications, and embedded systems today. SQLite writes the entire database on the host system as a single platform file.

The file base is SQLite. This is not the same as other SQL databases because SQLite does not have a separate server process like most other SQL databases. The installation process for SQLite on Debian 11 (Linux OS) is described in two ways in the article:

  • How to install SQLite from Debian repository
  • How to install SQLite from SQLite website

Before installing SQLite, update packages in one of the following ways:

Updating packages

Before installing any software, it is important to make sure your system is up to date by running the command below:

$ sudo apt update

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

$ sudo apt upgrade

Now all my packages are up to date and up to date.

Method 1: install SQLite from the Debian repository

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

Step 1. Installing SQLite on Debian 11

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

$ sudo apt install sqlite3

Step 2: Checking the version

To verify the installation, check the SQLite version number with the command below:

$ sqlite3 --version

Method 2: how to install SQLite using SQLite website

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

Follow these steps to successfully install the latest version:

Step 1. Install Build Tools

First we need to install the build tools to create a package, run the below command to install “build-essentials”:

$ sudo apt install build-essential

Step 2. Obtaining the SQLite Source Code

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

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

You can replace the SQLite source link if you install a different version in the wget command.

Step 3. Check out the source code

Run the command below to create a separate directory for extracting the source code into this folder:

$ mkdir SQLite

You can set the directory name of your choice.

Now change to the newly created directory using the command below:

$ cd SQLite

Now extract the SQLite source code with the tar command:

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

Step 4: Compiling the SQLite Source

To first compile the extracted source code, you need to access the generated folder using the command below:

$ cd sqlite-autoconf-3360000/

To start compiling, customize your code with the command below:

$ ./configure

Now use the make command to build libraries and executables from the SQLite source:

$ make

Step 5: Install SQLite

Now install sqlite 3.36.0 version using make command by executing below command:

$ sudo make install

Step 6: Verifying the Installation

To check if the latest version of SQLite is installed, check the version number with the command below:

$ sqlite3 --version

How to test SQLite

After successfully installing SQLite, you can create a database and table to test it working.

Create database “andreyex.db” using sqlite3 command as follows:

$ sqlite3 andreyex.db

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

CREATE TABLE linux(name String,version INT);

Insert data into the newly created table:

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

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

SELECT * FROM linux;

You can write more requests as per your requirement; this was just an example to show you how SQLite works in Debian 11 terminal.

Conclusion:

SQLite is a file-based relational database that contains the C library. It is a commonly used Database Engine and is primarily used in mobile applications. It writes the entire database on the host system as a single platform file. In this article, we have discussed installing SQLite on Debian 11 in two ways; from the Debian 11 repository and from the SQLite site using the wget command. Also discussed is how SQLite works using the sqlite3 command in the terminal. After reading this article, you should be able to successfully install and use SQLite on your Debian 11 system.

Related Posts