SQLite is a lightweight, open-source, serverless relational database management system (RDBMS) widely used in embedded systems and mobile devices. It is written in C and provides a simple yet powerful SQL interface for managing data.
When incorporated into Ubuntu, SQLite can benefit your workload or development project:
- It is easy to install and use, as it does not require a separate server or configuration. It can be integrated into your existing workflow with minimal effort.
- It is very lightweight and requires minimal resources, making it ideal for use on low-power devices or systems with limited resources.
- It is reliable and robust, with a proven track record of being used in mission-critical applications.
This tutorial will guide you through installing SQLite on Ubuntu 22.04 (Jammy Jellyfish) or Ubuntu 20.04 (Focal Fossa) using either the command line terminal and the APT package manager or by compiling and installing from the SQLite source code.
Step 1: Update Ubuntu
First, ensure that all packages on your system are up-to-date by running an update to prevent any conflicts during the installation of SQLite.
sudo apt update && sudo apt upgrade -y
Method 1: Install SQLite 3 with APT
The recommended approach to start with is to install SQLite using the default APT repository. To begin the installation, run the following command in your terminal.
sudo apt install sqlite3
After installation, you can verify the version of SQLite 3 by running the –version command.
sqlite3 --version
Example output:
3.37.2 2022-01-06 13:25:41
Step 2: Install SQLite from the Source
It is worth noting that the version of SQLite available in Ubuntu’s repository may not always be the most recent. Compiling the software from the source allows you to install the latest or a specific version of your preference.
To begin, you will need to install the build-essential package.
sudo apt install build-essential
After that, visit the SQLite Download page, obtain the link for the latest version, and download it using the wget command.
wget https://www.sqlite.org/2022/sqlite-autoconf-{version}
Here is an example command, please ensure you check the website for the latest link.
wget https://www.sqlite.org/2022/sqlite-autoconf-3400100.tar.gz
Once the download is complete, extract the files from the downloaded archive.
Example:
tar xvfz sqlite-autoconf-3400100.tar.gz
Now, you will navigate to the folder to begin compiling SQLite.
cd sqlite-autoconf-3400100
Begin the compilation process by running the command “./configure –prefix=/usr” to set the desired installation path.
./configure --prefix=/usr
If you receive the following error.
configure: error: in `/home/joshua/sqlite-autoconf-3400100':
configure: error: no acceptable C compiler found in $PATH
If you encounter this issue, you have not installed the package specified earlier in this section. To rectify this, you will need to install the build-essential package.
Example output if successful:
The standard starting the build process method is to use the “make” command. To optimize the process and speed it up, you can specify the number of cores you want to use in the compilation process by using the command “make -j(number of cores)”
make -j 2
Example output if successful:
Once the build process is finished, you can begin the installation using the following command.
sudo make install
Example output if successful:
Once installed, verify the installation and the version number.
sqlite3 --version
Example output:
3.40.1 2022-12-28 14:03:47
As mentioned above, the version is 3.40.1, whereas the Ubuntu repository version is 3.37.2, but your output will change in the future.
Conclusion
In conclusion, installing SQLite on Ubuntu is a straightforward process, whether you use the default APT repository or compile from the source. Whatever method you choose, it is important to remember that SQLite is a powerful and lightweight database management system that can be easily integrated into your workload or development project. Its robust feature set makes it an excellent choice for any application that requires a fast, reliable, and self-contained database. With the SQLite installation, you can quickly create and manage databases, tables, and other data structures.
For more information on building applications with SQLite, visit the official documentation page.