Google Colab Series — Setting up SQLite

Thivya
2 min readMay 13, 2022

--

SQLite is a lightweight relational database. You can read more about the features of SQLite from https://www.sqlite.org/about.html.

In this article, I would like to share how one could start using SQLite on their Google Colab notebook

  1. Load the sql extension , so that you could start using the %%sql
%load_ext sql

2. You could create an empty SQLite DB using the following command.

%%sqlsqlite:///test.db

Once you have executed the above command you can view the db file created in your working directory.

3. That’s it ! we are good to start using the SQLite DB.

%%sqlcreate table sample(column_1 int, column_2 varchar);insert into sample values (1,'abc'),(2,'abcd');select * from sample;

For those who prefer to deal setting up the database using a database tool, you can download the test.db file and connect it using a db tool.

An Example using DBeaver

(DBeaver — https://dbeaver.io/download/)

Create a New Database Connection
Create a SQLite Connection
Choose the file which you have downloaded
You can see the table and data in the db file
You can continue to create table and insert data to the db.

Once you have completed the setup required on the db, you can import the test.db file back to Google Colab workspace.

You can view the table and data from the test.db file

--

--

No responses yet