SQLite is a free, open-source, lightweight database engine written in C. It is a library for implementing a small, fast, self-contained, high-reliability, full-featured SQL database engine. Compared to other databases, SQLite engine is not a standalone process, and you will need to link it statically or dynamically as per your requirement.
In this post, we will show you how to install SQLite from a source on Fedora.
Step 1 – Remove SQLite Default Installation
By default, SQLite is already installed on the Fedora server. However, the installed SQLite version is an outdated version, so removing the SQLite and installing it again from the source is better.
First, verify the SQLite installed version with the following command.
sqlite3 --version
Output:
3.34.1 2021-01-20 14:10:07 10e20c0b43500cfb9bbc0eaa061c57514f715d87238f4d835880cd846b9ealt1
Next, remove the SQLite package using the following command.
dnf remove sqlite
Step 2 – Install SQLite from the Source
First, install all the required packages needed to compile SQLite.
dnf -y groupinstall "Development Tools"
Next, download the latest version of SQLite from their official website.
wget https://www.sqlite.org/2023/sqlite-autoconf-3410200.tar.gz
Next, extract the downloaded file using the following command.
tar -xvzf sqlite-autoconf-3410200.tar.gz
Next, navigate to the extracted directory and configure it with the following command.
cd sqlite-autoconf-3410200 ./configure
Output:
checking for zlib.h... yes checking for library containing deflate... -lz checking for library containing system... none required checking that generated files are newer than configure... done configure: creating ./config.status config.status: creating Makefile config.status: creating sqlite3.pc config.status: executing depfiles commands config.status: executing libtool commands
Next, run the following command to compile and install SQLite to your server.
make make install
Output:
/usr/bin/mkdir -p '/usr/local/bin' /bin/sh ./libtool --mode=install /usr/bin/install -c sqlite3 '/usr/local/bin' libtool: install: /usr/bin/install -c sqlite3 /usr/local/bin/sqlite3 /usr/bin/mkdir -p '/usr/local/include' /usr/bin/install -c -m 644 sqlite3.h sqlite3ext.h '/usr/local/include' /usr/bin/mkdir -p '/usr/local/share/man/man1' /usr/bin/install -c -m 644 sqlite3.1 '/usr/local/share/man/man1' /usr/bin/mkdir -p '/usr/local/lib/pkgconfig' /usr/bin/install -c -m 644 sqlite3.pc '/usr/local/lib/pkgconfig' make[1]: Leaving directory '/root/sqlite-autoconf-3410200'
Next, create a symbolic link of SQLite binary.
ln -s /usr/local/bin/sqlite3 /usr/bin/
Then, verify the SQLite version with the following command.
sqlite3 --version
Output:
3.41.2 2023-03-22 11:56:21 0d1fc92f94cb6b76bffe3ec34d69cffde2924203304e8ffc4155597af0c191da
Step 3 – Create a Database and Table in SQLite
First, create a new database using the following command.
sqlite3 mydb.db
Output:
SQLite version 3.41.2 2023-03-22 11:56:21 Enter ".help" for usage hints. sqlite>
Next, exit from the SQLite shell with the following command.
.exit
Next, change the database to mydb.db database and create a table named students using the following command.
sqlite3 mydb.db CREATE TABLE students (id INTEGER PRIMARY KEY, name TEXT, position TEXT);
Next, insert some rows in the created table.
INSERT INTO students (name, position) VALUES ('Hitesh Jethva', '12th'); INSERT INTO students (name, position) VALUES ('Jay Jethva', '10th'); INSERT INTO students (name, position) VALUES ('Vyom Jethva', '5th');
You can now verify the inserted data using the following command.
SELECT * FROM students;
You will see all your data in the following output.
1|Hitesh Jethva|12th 2|Jay Jethva|10th 3|Vyom Jethva|5th
Conclusion
In this post, we showed you how to install SQLite from the source on Fedora. We also explained how to create a database and table in SQLite. You can now try SQLite on VPS hosting from Atlantic.Net!