SQLite – Linux Hint https://linuxhint.com Exploring and Master Linux Ecosystem Mon, 01 Mar 2021 00:17:41 +0000 en-US hourly 1 https://wordpress.org/?v=5.6.2 Install SQLite browser in Ubuntu 20.04 https://linuxhint.com/install_sqlite_browser_ubuntu/ Tue, 04 Aug 2020 16:16:46 +0000 https://linuxhint.com/?p=64861 SQLite is a lightweight command-line database application. It is a cross-platform software that can be installed onto a variety of operating systems, such as Linux, Windows, Mac OS, and more. SQLite is not like a client-server based database application, but rather is a relational database management system embedded in the C library. The front end of SQLite is the SQLite browser, which graphically works with the SQLite databases. SQLite browser is a graphical tool used for designing, creating, and editing the SQL databases that are compatible with SQLite. This program was created for developers who want to create their own databases, search information, and edit data.

SQLite has a friendly, spreadsheet-like interface, and you do not need to put much effort into learning the complex SQL commands. At the time of writing this article, SQLite 3 was the latest available version. SQLite 3 and SQLite browser are available for installation in the official apt repository of Ubuntu 20.04.

This article will show you how to install the SQLite browser and the SQLite 3 database in Ubuntu 20.04 LTS.

Installing SQLite 3 on Ubuntu 20.04


To install SQLite 3 onto your Ubuntu system using the command line, first open the terminal application. You can access the terminal by pressing Ctrl + Alt + t or by using the Application Launcher. After opening the terminal, update the cache apt repository by executing the following command:

$ sudo apt update

Before installing any new package or software, you must make sure that the apt repository has been updated.

You can search for all available SQLite packages in the apt repository using the following command:

$ sudo apt-cache search sqlite

Next, install SQLite 3 using the following command:

$ sudo apt install sqlite3

Before installing the SQLite browser, SQLite 3 must be installed on your system.

To verify the installation and functioning of SQLite 3, run the following command in the terminal:

$ sqlite3 --version

As shown above, SQLite 3.31.1 is now installed on your Ubuntu 20.04 system.

Installing SQLite browser in Ubuntu 20.04

Follow the steps below to install the SQLite browser onto your Ubuntu 20.04 system:

Step 1: Update apt-cache

Before installing the SQLite browser, it is recommended that you update the apt-cache repository on your system using the following command:

$ sudo apt update

Step 2: Install SQLite Browser Using the apt Repository

Execute the following command to install the SQLite browser in Ubuntu 20.04:

$ sudo apt install sqlitebrowser

During the installation of the SQLite browser, you will be prompted as to whether you would like to continue installing or if you want to quit. Press ‘y’ and hit Enter to complete the installation of the SQLite browser onto your system.

Once the installation is completed, it is now time to launch the SQLite browser on your system.

Step 3: Launch SQLite Browser

Launch the SQLite browser by accessing the application launcher and typing the term “SQLite browser” into the search bar. After hitting Enter, you will see the following search result appear on your system:

Click on the SQlite browser icon and open the user interface. The following interface will be displayed on your system.

As you can see, the SQLite browser has been installed on the Ubuntu 20.04 system. If you want to check which version of the SQLite browser is installed on your system, then you can check it using the following command:

$ sqlitebroswer –version

In the above image, SQLite browser version 3.11.2 is installed on this system.

Uninstall or Remove SQLite Browser

If you no longer wish to use this tool, then you can also uninstall or remove SQLite browser from your system. To completely remove SQLite browser along with all its configurations, execute the following command in the terminal:

$ sudo apt --purge remove sqlitebrowser

Conclusion

This article explained how to install the SQLite 3 database and SQLite browser on Ubuntu 20.04 using terminal commands. You can explore the various features of the SQLite browser using this tool on your Ubuntu system.

]]>
Install SQLite and SQLite Browser on Ubuntu 18.04 LTS https://linuxhint.com/install_sqlite_browser_ubuntu_1804/ Sun, 13 May 2018 06:08:40 +0000 https://linuxhint-com.zk153f8d-liquidwebsites.com/?p=26084

SQLite is a lightweight database software. It is a command line application. You must use the command line or SQLite API on other programming languages to use SQLite database. SQLite has a graphical front end SQLite Browser for working with SQLite databases graphically.

SQLite 3 is the latest version at the time of this writing. SQLite 3 is available in the official package repository of Ubuntu 18.04 LTS. SQLite Browser is also available in the official package repository of Ubuntu 18.04 LTS.

In this article, I will show you how to install SQLite 3 and SQLite Browser on Ubuntu 18.04 LTS. I will also show you some of the basic queries of SQLite 3. Let’s get started.

Installing SQLite 3

First update the apt package repository cache with the following command:

$ sudo apt-get update

The apt package repository cache should be updated.

Now to install SQLite 3, run the following command:

$ sudo apt-get install sqlite3

SQLite 3 should be installed.

Now you can check whether SQLite 3 is working with the following command:

$ sqlite3 --version

Installing SQLite Browser

Run the following command to install SQLite Browser:

$ sudo apt-get install sqlitebrowser

Now press y and then press <Enter>.

SQLite Browser should be installed.

Using SQLite using SQLite Browser

Now you can go to the Application Menu and search for SQLite Browser. You should see a database icon as marked in the screenshot below. Click on it.

SQLite Browser should start as you can see in the screenshot below.

Getting Started with SQLite 3 using SQLite Browser

In this section, I will show you the basics of SQLite 3 database with SQLite Browser graphical user interface.

First click on New Database to create a new database using SQLite Browser.

You should see the following dialog window. Type in a filename and save it somewhere on your filesystem.

Now you should the following window. Using this window, you can create your first SQLite 3 table.

Enter the name of the table. If you want to follow along, users table it is.

Now you can click on Add field button to add as many fields or columns on your table.

Once you click on Add field button, you should see a new field as marked in the screenshot below.

I named the field id, changed the Type to INTEGER, checked the Not null, PK (Primary Key), AI (Auto Increment) checkboxes.

I added name and country field, set their Type to TEXT and checked the Not null checkboxes.

In the marked section of the screenshot below, you can find the SQL code. You can run this code in the SQLite 3 command line interface and create an identical users table as well. SQLite Browser is an awesome tool to lean SQLite as well.

Once you’re happy with your table, click on OK.

users table should be created.

Now I will show you how to insert data into the users table.
First go to the Browse Data tab as marked in the screenshot below.

Now select the users table from the marked section of the screenshot below.

Once users table is selected, click on New Record button to add a new row or data into the table.

The id should be auto generated. The name and the country field should be blank. Click on each of them and type in your desired data.

As you can, I added a new row to the users table.

Now to save the changes, click on Write Changes button as marked in the screenshot below.

The changes should be written to the file on your filesystem.

If you want, you can execute SQL statements on SQLite Browser as well.

To execute SQL statements, first go to the Execute SQL tab as marked in the screenshot below.

Enter your SQL statements in the marked section of the screenshot below.

I wrote a simple SQL statement, SELECT * FROM users.

Now if you want to execute the SQL statement, click on the play button as marked in the screenshot below. You can also press F5 or <Ctrl> + r

As you can see, the data is returned.

You can insert into the users table with the following SQL command:

INSERT INTO users(name, country) VALUES(‘John Doe’, ‘US’);

Now if you run SELECT * FROM users again, you should see the new data.

Exporting SQLite Database using SQLite Browser

You can export the SQLite database using SQLite Browser.

First open the SQLite database from File > Open Database…

Now select your SQLite database file and click on Open.

Your database should be opened.

Now you can click on File > Export and then select either Database to SQL file… or Table(s) as CSV file… or Table(s) to JSON… to export the database to your desired format.

You should see the following window. Now select the tables that you want to export from the Table(s) section. By default, all the tables are selected.

You can also change some options to configure how the exported file should be formatted.

Once you’re happy, click on OK.

Now select the file path, type in a filename and click on Save.

The database should be exported, now click on OK.

As you can see, the database was exported as SQL.

So that’s how you install SQLite 3 and SQLite Browser on Ubuntu 18.04 LTS, and use SQLite Browser. Thanks for reading this article.

]]>
Install Sqlite on Arch Linux https://linuxhint.com/install-sqlite-arch-linux/ Tue, 06 Mar 2018 13:30:24 +0000 https://linuxhint-com.zk153f8d-liquidwebsites.com/?p=23397

How to Install SQLite on Arch Linux

SQLite is a lightweight file based database system. It does not have any dependencies like other big databases. SQLite uses less memory, so it is ideal for embedded systems like Android. You can also use SQLite for your websites and apps if it doesn’t need to store too much data.

SQLite is a great database. Since it’s a file based database system, it has some limitations. The file size of a single SQLite database file depends on the file system you created the file on. For example, on FAT 32 file system, the SQLite database file can be as big as 4GB. To avoid the limitations of SQLite, you should use a file system that supports a big file. That’s it.

If you think your database file might be larger than the largest file your file system supports, you should consider using another database system like MySQL or MariaDB or PostgreSQL.

SQLite is open source and a cross platform database.

In this article, I will show you how to install SQLite on Arch Linux. Let’s get started.

Installing SQLite

First update the pacman package repository cache of your Arch machine with the following command:

$ sudo pacman -Sy

The pacman package repository cache should be updated.

SQLite version 3, which is the latest version at the time of this writing, is available in the official package repository of Arch Linux.

You can run the following command to install SQLite 3 on Arch Linux:

$ sudo pacman -S sqlite

Now press ‘y’ and then press <Enter> to continue.

SQLite 3 should be installed.

Once the installation is complete, you can run the following command to check whether SQLite is working:

$ sqlite3 --version

As you can see from the screenshot below, the version of SQLite is installed is 3.22.0.

Using SQLite

In this section I will show you how to use SQLite 3 database system.

You can use SQLite 3 using the sqlite3 command line interface or you can use DB Browser for SQLite to use SQLite 3 graphically. I will show you how to use SQLite graphically using DB BrowserDB Browser for SQLite is available in the official package repository of Arch Linux.  You can install DB Browser for SQLite on Arch Linux with the following command:

$ sudo pacman -S sqlitebrowser

Now press ‘y’ and then press <Enter> to continue.

DB Browser for SQLite should be installed.

Now you can go to Activities or Application Menu of your desired desktop environment and look for SQLite and you should see DB Browser for SQLite icon as shown in the screenshot below. Click on it.

DB Browser for SQLite should start as shown in the screenshot below.

You can click on New Database to create a new SQLite 3 database using DB Browser for SQLite.

Once you click on New Database, you should be prompted to save the SQLite database as shown in the screenshot below. Type in a file name and click on Save.

Once you click on Save, you should see the following window.

Type in a table name in the marked section of the screenshot below. I am going to call it users table.

Now click on Add field button as marked in the screenshot below.

You should see a new field Field1 being created.

Now change the field name from Field1 to id, leave the Type to INTEGER and mark the PK, AI and Not null checkboxes as shown in the screenshot below.

Now click on Add field button again, create a new field firstname and change the Type to TEXT, and mark the Not null checkbox as shown in the screenshot below.

Now click on Add field button again, create a new field lastname and change the Type to TEXT, and mark the Not null checkbox as shown in the screenshot below.

This is enough to demonstrate how to use DB Browser for SQLite to work with SQLite 3 databases. So click on OK as marked in the screenshot below.

The table is shown in the left side of the DB Browser window.

Now to insert data into the table, to go the Browse Data tab, change the table to users and click on New Record as marked in the screenshot below.

As you can see, an empty record is added.

You can click on the record and modify it as you need.

Once you’re done, you can click on Write Changes button as marked in the screenshot to save the changes to the database.

You can also open the database file with SQLite’s command line interface as well as follows:

$ sqlite3 ~/Desktop/users

The users SQLite 3 file should be opened with SQLite 3 as shown in the screenshot below.

Now run the following SQL statement to select all the rows of users table.

sqlite> SELECT * FROM users;

As you can see, the data I saved using DB Browser is there.

That’s how you install SQLite and use it on Arch Linux. Thanks for reading this article.

]]>
Backup and Restore of Sqlite Database https://linuxhint.com/backup-restore-sqlite/ Fri, 02 Feb 2018 04:04:53 +0000 https://linuxhint-com.zk153f8d-liquidwebsites.com/?p=21989

How to Backup and Restore Data from SQLite on Ubuntu

SQLite is a simple but very powerful database software. It is a very lightweight database solution. It is used mostly in low power, handheld, or embedded devices like Android due to it being lightweight. It is a file based database software. That means, you store everything in a single file and you can easily store that wherever you want without any complex configuration. Though you can store everything in a single file, it doesn’t mean you can’t store part of your data in a file, another part in another file. You can also store one table in one file, another table in another file and so on. Of course you can do these type of management with SQLite with ease. It doesn’t require much memory to run as well. You can manage everything with simple command line utilities that comes with SQLite. Currently the latest version of SQLite is 3.

In this article, I will show you how to backup and restore SQLite database on Ubuntu. Let’s get started.

Installing SQLite

SQLite is available in the official package repository of your Ubuntu operating system. There are 2 versions of SQLite in the official package repository of Ubuntu. SQLite 2 and SQLite 3. I will show you how to install both of these in this article.

First update the package repository cache of your Ubuntu operating system with the following command:

$ sudo apt-get update

The package repository cache should be updated.

Now to install SQLite 2 on Ubuntu, run the following command:

$ sudo apt-GET install sqlite

Now press ‘y’ and press <Enter> to continue.

SQLite 2 should be installed.

To install SQLite 3 on Ubuntu, run the following command:

$ sudo apt-GET install sqlite3

I will install SQLite 3 and do the rest of the demonstration with SQLite 3 in this article. But everything should work the same way in SQLite 2. You can safely replace sqlite3 command with sqlite command.

Note that you can install both versions of SQLite at the same time. They have no problem coexisting with each other.

Inserting Dummy Data:

You can start working on a SQLite database file with SQLite 2 with the following command:

$ sqlite test.db

SQLite should open a test.db file. If the file doesn’t exist, it should create a new one once you save some data in it.

For SQLite 3, the command above should be:

$ sqlite3 test.db

Now I am going to create a simple table and insert some dummy data there.
The SQL code for the users table is given below:

CREATE TABLE users (
id INTEGER PRIMARY KEY,
firstName TEST NOT NULL,
lastName TEXT NOT NULL,
country TEXT NOT NULL
);

Just copy and paste the SQL code into the command line interface of SQLite. The users table should be created.

Now run the following SQL codes to insert some dummy data into the table.

INSERT INTO users VALUES(1, 'Alex', 'Cooper', 'USA');
INSERT INTO users VALUES(2, 'Shahriar', 'Shovon', 'BD');
INSERT INTO users VALUES(3, 'Sharmin', 'Akter', 'BD');
INSERT INTO users VALUES(4, 'MD', 'Shaikat', 'BD');

You can run the following SQL command to retrieve all the users data from the table.

sqlite> SELECT * FROM users;

Once you’re done, run the following command to exit sqlite command line interface.

sqlite> .exit

Backing up and Restoring SQLite Database:

File Based Backup:

The best way to backup and restore SQLite database is to copy the database file to another location and paste the backed up database file when you need. In the example of this article, I stored all the SQLite data to the test.db file as you can see from the screenshot below.

I am going to copy the test.db file to another location with the following command:

$ cp -v test.db Dowloads/test.db.backup

Now I am going to start SQLite using the backup database file.

$ sqlite3 Downloads/test.db.backup

Now run the following SQL command, and you should see all the data.

$ SELECT * FROM users;

Backup as SQL File:

You can also backup a SQLite database using the SQLite command. This output or backup file in this way will contain all the necessary SQL codes to reconstruct the database.

Run the following command to backup the test.db database file to backup.sql SQL file:

$ sqlite3 test.db .dump > backup.sql

You can run the following command to see the contents of backup.sql file:

$ cat backup.sql

As you can see, it contains only SQL codes.

To restore another database test2.db from backup.sql backup file, run the following command:

$ sqlite3 test2.db < backup.sql

Now you can login to the test2.db SQLite database with the following command:

$ sqlite3 test2.db

Now run the following SQL code and you should be able to see all the data there.

$ SELECT * FROM users;

That’s how you backup and restore data from SQLite database on Ubuntu. Thanks for reading this article.

]]>
SQLite Tutorial https://linuxhint.com/sqlite-tutorial/ Thu, 14 Dec 2017 09:35:20 +0000 https://linuxhint-com.zk153f8d-liquidwebsites.com/?p=20780 Ever since man started creating systems, there have always been databases corresponding to them. Fast forwarding to our present day where technology has evolved, and nearly everything has now been automated. While developing systems and applications, SQL has been the leading language which developers use to create and administer databases. For SQL to run properly, it needs an engine. This engine is then responsible for handling operations and transactions throughout the database.

What is SQLite?

SQLite is a fast and simple open source SQL engine. While this engine might have others confused with full RDBMS’s such as Postgres and MySQL, SQLite is different and performs at its peak in certain conditions. SQLite is a new library that enforces a serverless, self-contained, no setup SQL database engine. Since it does not need configuration like other databases, it is easier to use and install. Unlike other databases, it is not a standalone process. You can link the database to your application so that the records it stores can be accessed either dynamically or statically.

There has always been a misconception about SQLite being only for development and testing. While it is a great tool for that job, it is not only limited to system testing. For instance, SQLite can handle a website receiving more than 100,000 visits per day on the lower side. The maximum size limit for SQLite is 140 Terabytes which is more than what most applications clock.

Why should you use SQLite?

  • Since the system is serverless, it does not need an additional server process to function.
  • There being no configuration, there is no need for setup or monitoring administrators.
  • SQLite is compact as a full SQLite database can fit in one cross-platform disk file. Fully configured on a system, the whole database can be about 400KiB or about 250KiB when some features have been omitted.
  • Supports most of SQL92 (SQL2) query language features thus quite familiar.

Since it is written in ANSI-C, the API is easy to use and quite straightforward.


INSTALLATION

Since SQLite’s pride comes from its surprisingly simple configuration, the installation process is quite straightforward. In this tutorial, we shall focus more on Linux than other platforms. These days we find that SQLite is being shipped with almost all the versions of Linux operating system. So, before bothering to install it, you should check whether the installation has already taken place. To be sure, type this:

$ sqlite3

If properly installed, you should see the following result:

SQLite version 3.7.15.2 2013-01-09 11:53:05

Enter ".help" for instructions

Enter SQL statements terminated with a ";"

sqlite>

If not, it means SQLite has not been installed on your system. To install, you can;

Go to the SQLite official page and download SQLite-autoconf-*.tar.gz from the section with the source codes. After that, open command line and run the following command;

$tar xvfz SQLite-autoconf-3071502.tar.gz

$cd SQLite-autoconf-3071502

$./configure --prefix = /usr/local

$make

$make install

You can also use the following method to install:

sudo apt-get update

sudo apt-get install sqlite3

Both these methods will do the same thing. You can confirm that installation is complete by running the first test.


Meta commands

Meta commands are mostly used for administrative operations such as examining databases and defining output formats. The unique thing about all these commands is that they always start with a dot (.). Here are some of the more common ones that come in handy over time.

Command Description
.dump Dump database usually SQL text format
.show Displays the current settings for various parameters
.databases Provides complete database names and files
.quit Quits the SQLite3 program
.tables Show a list of all current tables
.schema Display schema of the table
.header Hides or displays the output table header
.mode Select mode for the output table

Standard Commands

When dealing with SQLite, there exist common commands used for various activities in the database. They are referred to as standard commands since they are usually the most frequently used ones. They are classified into three groups owing to their various functions across the scope.

Data definition language

The very first group are the commands responsible for storage structure and also methods of data access from the database. They are:

  • CREATE
  • DROP
  • ALTER

Data manipulation language

These are the commands mostly used to manipulate data in the database. Data manipulation includes adding, removing and modifying the data. In this section, we have:

  • INSERT
  • UPDATE
  • DELETE

Data query language

The last type of commands are those that enable the users to fetch certain data from the databases. Here we only have one:

  • SELECT

It is important noting that these are not the only commands SQLite can support. However, since we are at the beginner stage, we shall only be exploring these for now.


Creating a database

When dealing with SQLite3, commands are used to create a new database. Unlike other RDBMS’s, you need not have special privileges to do this. Remember that the database name should be unique. The following is the syntax for creating a database:

sqlite3 DatabaseName.db

A new database called linuxDB would be written as follows

$ sqlite3 linuxDB.db
SQLite version 3.21.0 2017-10-24 00:53:05
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
SQLite>

You can confirm the creation of the database by using the .databases command.

sqlite>.databases
seq  name             file
---  ---------------  ----------------------
0    main             /home/SQLite/linuxDB.db

Creating tables

Since tables are the skeletal of the database, it is essential to know how to create them. To create a table means you have to name the table, define the columns and the data type for each column. This is the syntax for creating a table.

CREATE TABLE database_name.table_name(
column1 datatype PRIMARY KEY(one or more columns),
column2 datatype,
column3 datatype,
…..
columnN datatype
);

In action, this is what a sample table called product_x will look like. The ID is the primary key. You should always remember to specify fields that cannot be null.

sqlite> CREATE TABLE product_x(
   ID INT PRIMARY KEY     NOT NULL,
   NAME           TEXT    NOT NULL,
   UNITS          INT     NOT NULL,
   PRICE          INT,
   DISCOUNT       REAL
);

Drop table

This command is used when the developer wants to remove a table together with all its contents. You should always be careful when using this command since once the table is deleted, all subsequent data is lost forever. This is the syntax:

DROP TABLE database_name.table_name;

sqlite> DROP TABLE product_x;

Alter table

This command is used to edit the contents of a table without having to dump and reload the data. In SQLite, there are only two operations you can perform on a table with this command; renaming a table and adding or removing current columns.

This is the syntax for renaming an already existing table and adding a new column respectively;

ALTER TABLE database_name.table_name RENAME TO new_table_name;
ALTER TABLE database_name.table_name ADD COLUMN column_def…;

For example, a table named product_x can be renamed to product_yz and we can add a new column to product_yz in the two lines of code below:

sqlite3> ALTER TABLE product_x
 ...> RENAME TO product_yz;

sqlite3> ALTER TABLE product_yz
 ...> ADD COLUMN manufacturer_name TEXT;

Insert query

The INSERT INTO command is used to add rows of data into a table inside the database. The syntax for this is quite direct:

INSERT INTO TABLE_NAME VALUES (value1,value2,value3,…valueN);

Column1, column2,…columnN are the names of the columns belonging to the table you want to insert data. It is important to specifically note the column name in SQLite when adding values to all columns in the table.

SELECT Query

The SELECT statement in SQLite is primarily used to fetch data from the SQLite database and return said data in the form of a results set. This is the syntax for using the SELECT statement;

SELECT column1, column2, columnN FROM table_name;

From the above syntax, column1, column2 … are the respective fields in the table where you want to fetch values. In case you want to fetch all fields in that table, then you use the following syntax. The wildcard (*) basically means ‘all’.

SELECT * FROM TABLE_NAME;

UPDATE Query

In a database, records need to change for one reason or another. Supposing a user wants to change their email address on your platform, this is exactly the command you need to make this process work. While using the UPDATE clause, we must also use the WHERE clause to update the selected rows. If not, you will find all the rows have been updated! That would be really bad. This is the syntax for performing this operation:

UPDATE table_name
SET column1 = value1, column2 = value2…., columnN = valueN
WHERE [condition];

If you have an N number of conditions to be met, the AND or OR operators come in very handy. Example:

sqlite> UPDATE product_x
 ...> SET UNITS = 103 WHERE ID = 6;

The AND & OR operators

These are what could be called conjunctive operators. They are used to compile several conditions in order to shrink the selected data in an SQLite environment. These operators make it possible for a developer to make multiple comparisons of values using different operators on one SQLite statement.

The AND operator is unique since it allows the user to have multiple conditions in conjunction with the WHERE clause. When using this operator, the condition is regarded as true if all the conditions are met. This is the syntax for the AND operator.

SELECT column1, column2, columnN
FROM table_name
WHERE [condition1] AND [condition2]…AND [conditionN];

On the flip side of things, we have the OR operator which is also used together with the WHERE clause. Unlike the AND operator, the condition is true if one of the conditions has been met. The syntax is pretty simple.

SELECT column1, column2, columnN
FROM table_name
WHERE [condition1] OR [condition2]…OR [conditionN]

Sources and Additional Info

http://linuxgazette.net/109/chirico1.html
http://www.yolinux.com/TUTORIALS/SQLite.html
https://www.sitepoint.com/getting-started-sqlite3-basic-commands/
https://www.digitalocean.com/community/tutorials/how-and-when-to-use-sqlite
http://www.thegeekstuff.com/2012/09/sqlite-command-examples/?utm_source=feedburner

]]>
Upgrade To Latest SQLite3 on CentOS7 https://linuxhint.com/upgrade-to-latest-sqlite3-on-centos7/ Sat, 09 Dec 2017 18:31:09 +0000 https://linuxhint-com.zk153f8d-liquidwebsites.com/?p=20679 How to Upgrade to the Latest SQLite3 on CentOS7

SQLite 3 is a lightweight simple file based database system. It is used by many developers. Especially devices that have low hardware specs, microcontrollers, embedded computers use SQLite as a lightweight database system. Android also make extensive use of SQLite database.

In CentOS 7, SQLite 3.7 is already installed. You can’t remove it because all the other packages of CentOS 7 depend on it. CentOS 7 don’t provide any way to update it. Updating the version of SQLite on CentOS 7 is also tricky because of that.

In this article, I will show you how to update SQLite3 on CentOS 7 safely. Let’s get started.

Downloading Latest SQLite3:

First go to the official website of SQLite at https://sqlite.org.  You should see the following page:

Now click on “Download” as shown in the screenshot below.

You should see the following page. It contains download links for the latest version of SQLite3.

Now scroll down a little bit. You should see the section “Precompiled Binaries for Linux”. From here, you can download precompiled version of latest stable SQLite3 database. Precompiled binaries are ready to use after download, as they don’t require compilation of any sort. Click on the file as shown in the screenshot.

Your browser should prompt you to download the file. Click on “Save File” and click on “OK”. Your download should start.


Upgrading SQLite3:

Now open a Terminal and go to the directory where you downloaded SQLite3. It should be ~/Downloads directory in your USER’s home directory by default.

Run the following command to go to the ~/Downloads directory:

$ cd ~/Downloads

Now let’s list the contents of the ~/Downloads directory with the following command:

$ ls

You can see that the downloaded file is there.

Now we have to extract the zip archive.

To extract the downloaded zip file, run the following command:

$ unzip sqlite-tools-linux-x86-3210000.zip

There are only 3 files inside the zip file as you can see. They are ‘sqlite3’, ‘sqldiff’, ‘sqlite3_analyzer’

We are interested in ‘sqlite3’ file only.

Now we have to locate where the preinstalled sqlite3 program is.

To do that, run the following command:

$ whereis sqlite3

You can see that, the preinstalled SQLite3 program is in ‘/usr/bin/sqlite3’. Take a note of that as we need this path later.

You can remove ‘/usr/bin/sqlite3’ file and replace it with the update one. But I don’t recommend doing that. Because if any problem arises, you won’t be able to go back that easily. I recommend renaming the file. So you will have both of these SQLite3 installed and the updated one will be the default. In case you have any problem, just remove the new one and rename the old one to ‘sqlite3’ you’re done.

Before I rename the file, let’s check the version of the SQLite3 currently installed.

Run the following command:

$ sqlite3 --version

You can see that the version is 3.7.17.

I will rename the installed SQLite3 binary from ‘sqlite3’ to ‘sqlite3.7’.

To do that, run the following command:

$ sudo mv -v /usr/bin/sqlite3 /usr/bin/sqlite3.7

You can see that, the rename operation was successful.

Now we can copy the latest stable sqlite3 binary that we got after we unzipped the downloaded zip archive to /usr/bin/.

To do that, run the following command:

$ sudo cp -v sqlite-tools-linux-x86-3210000/sqlite3 /usr/bin/

You can see the that the copy operation was successful.

Now you can check the version of the installed SQLite3 again with the following command:

$ sqlite3 --version

You can see that the version if 3.21. That is the latest version as of this writing.

You can also use the old version if you want. The old SQLite3 can be accessed as ‘sqlite3.7’ as shown in the screenshot below.

So that’s how you update SQLite3 on CentOS 7. Thanks for reading this article.

]]>
How to install SQLite 3 in Ubuntu 20.04 and Linux Mint 20 https://linuxhint.com/install-sqlite-ubuntu-linux-mint/ Tue, 28 Mar 2017 16:54:09 +0000 https://linuxhint-com.zk153f8d-liquidwebsites.com/?p=18614

SQLite is a free, lightweight, and command-line database application. It is an efficient database engine that is implemented in C. It is a cross-platform database application. Like SQL and MySQL, SQLite is also a relational database. It is widely used in combination with Android and web applications. SQLite is leveraged with an SQLite browser. SQLite Browse is a graphical and free software platform for developing and designing, SQLite databases. In this post, you will get to know the installation procedure of SQLite 3 and SQLite Browser on Linux Mint 20 Ubuntu 20.04.

Installing SQLite 3 in Ubuntu 20.04 and Linux Mint 20

To install SQLite 3 on Ubuntu 20.04 and Linux Mint 20, perform the following steps:

Step 1: Update apt repository cache

Before installing any application or package, it is recommended to update the system apt repository cache using the following command:

$ sudo apt update

Step 2: Update apt-cache

Next, upgrade the apt repository cache using the following command:

$ sudo apt upgrade

Step 3: Install SQLite 3

Alright! Now we are ready to install SQLite 3 on Ubuntu 20.04 and Linux 20. SQLite is available through Ubuntu 20.04 and Linux Mint 20 repositories. Install SQLite 3 using the following command:

$ sudo apt install sqlite3

Step 4: Verify the installation

After installing SQLite 3, we can view the installed version of SQLite 3. Additionally, it also verifies the installation. Run the below-given command to do so:

$ sqlite3 –version

Installing SQLite browser in Ubuntu 20.04 and Linux Mint 20

The SQLite browser can be installed in Ubuntu 20.04 and Linux Mint 20 through the below-given steps:

Step 1: Update apt repository cache

Before installing the SQLite browser, update the system’s apt repository cache with the following command:

$ sudo apt update

Step 2: Install SQLite browser on your Ubuntu 20.04 and Linux Mint 20

The SQLite browser can be installed by executing the following command:

$ sudo apt install sqlitebrowser

The command line will display a prompt. You are supposed to press “y” to continue the installation process. However, if you want to cancel the installation process then press ‘n’ and hit enter.

Step 3: Launch SQLite browser

After the successful installation, click on the application menu and search for SQLite browser and open it.

It is the main window of SQLite bowser.

Removing SQLite 3 from Ubuntu 20.04 and Linux Mint 20

At any point, if you want to remove or uninstall the SQLite 3 from your system, run the following command to do so:

$ sudo apt --purge remove sqlitebrowser

Conclusion

SQLite 3 is a free and efficient database engine. This article explains how to install SQLite 3 on Ubuntu 20.04 and Linux Mint 20.

]]>
How to Install SQLite Browser in Ubuntu 20.04 https://linuxhint.com/install-sqlite-browser-ubuntu/ Sat, 04 Feb 2017 19:00:12 +0000 http://sysads.co.uk/?p=16356

The SQLite Browser is an application with a Graphical User Interface (GUI) that is used for performing CRUD operations and editing SQL DB files compatible with SQLite. This application also provides greater ease to users and developers in creating databases, as well as searching and editing data. The SQLite Browser uses an interface familiar to a spreadsheet so that there is no need to learn complicated SQL commands. This article shows you to install SQLite 3 and the SQLite Browser in Ubuntu 20.04 LTS using the apt and snap methods.

Installation of SQLite 3 in Ubuntu 20.04 LTS

Before installing the SQLite browser, you will first need to install SQLite3. Installing SQLite 3 in Ubuntu is as simple as installing any other package in Ubuntu.

First, update the apt-cache repository by issuing the following:

$ sudo apt update

After updating the cache, install SQLite 3.

You can search for the SQLite packages in the apt repository to check whether they exist in the apt repository. To search for the SQLite packages in the apt repository, run the following command:

$ sudo apt-cache search sqlite

The output of this command will list all the packages in the apt repository related to SQLite. After searching for the desired package, if it exists in the list, you can install SQLite 3 using the simple apt install command in the terminal.

To install SQLite 3, run the command below:

$ sudo apt install sqlite3

Once the installation is completed, you will see the following:

You can verify the installation of SQLite 3 by running the sqlite3 –version command, as follows:

$ sqlite3 --version

The latest version 3.31 of SQLite 3 can be seen in the screenshot above, which shows that SQLite 3 has been installed successfully.

Installing SQLite Browser in Ubuntu 20.04 LTS

After successfully installing SQLite 3, you are now ready to install and get started with the SQLite Browser application. The SQLite Browser package can be installed using either of two methods:

  1. Install SQLite Browser Using Apt Repository
  2. Install SQLite Browser Using Snap

The following sections show you how to install the SQLite Browser using both methods.

Method #1: Install SQLite Browser Using Apt Repository

To install the SQLite Browser using the apt repository, first, update your system’s apt-cache repository.

$ sudo apt update

Next, install the SQLite Browser via the following command:

$ sudo apt install sqlitebrowser

You will then be asked whether you want to continue to take additional disk space or quit the installation process. Press ‘y’ to continue the installation.

Once the installation of SQLite Browser has completed, you are now ready to launch and use the SQLite browser in your Ubuntu system.

Starting the SQLite Browser

To start the SQLite Browser, simply search for the SQLite Browser in the Application Menu.

Then, click the SQLite Browser Icon to open it.

Shown in the image above is the Welcome screen of the SQLite Browser.

You can verify the installation of SQLite Browser from the terminal by running the sqlitebrowser –version command in the terminal, as follows:

$ sqlitebrowser --version

In the above screenshot, you can see the SQLite Browser version.

Uninstalling the SQLite Browser

To uninstall the SQLite Browser from your Ubuntu system, issue the following command:

$ sudo apt --purge remove sqlitebrowser

As you can see in the screenshot above, the SQLite Browser has been uninstalled successfully.

Method #2: Install SQLite Browser Using Snap

To install SQLite Browser in Ubuntu via the snap repository, first, update the apt-cache repository.

$ sudo apt update

Also, make sure that snap is installed on your Ubuntu system. If you do not have snap installed, run the command below to install snap:

$ sudo apt install snapd

After snap has successfully installed (or if you already have snap on your system), execute the sqlitebrowser installation command to install the SQLite Browser snap:

$ sudo snap install sqlitebrowser

After running the above command, SQLite will be installed, and you will be able to use it for your computing needs.

Conclusion

The SQLite Browser is the browser used to perform CRUD operations and many other operations in the SQLite database. Installing SQLite onto your Ubuntu system can be very easy, as was clearly explained in this article.

]]>