Programming with Databases in Python using SQLite

Parul Pandey
Analytics Vidhya
Published in
11 min readSep 11, 2018

--

Photo Credit: Pixabay

If you are aspiring to be a data scientist you are going to be working with a lot of Data. Much of the data resides in Databases and hence you should be comfortable accessing data from databases through queries and then working on them to find key insights.

Data forms an integral part of the lives of Data Scientists. From the number of passengers in an airport to the count of stationary in a bookshop, everything is recorded today in form of digital files called databases. Databases are nothing more than electronic lists of information. Some databases are simple, and designed for smaller tasks while others are powerful, and designed for big data. All of them, however, have the same commonalities and perform a similar function. Different database tools store that information in unique ways. Flat files use a table, SQL databases use a relational model and NoSQL databases use a key-value model.

In this article, we will focus only on the Relational Databases and accessing them in Python. We will begin by having a quick overview of the Relational databases and their important constituents.

Relational Database: A Quick Overview

A Relational database consists of one or more tables of information. The rows in the table are called records and the columns in the table are called fields or attributes. A database that contains two or more related tables is called a relational database i.e interrelated data.

The main idea behind a relational database is that your data gets broken down into common themes, with one table dedicated to describing the records of each theme.

i) Database tables

Each table in a relational database has one or more columns, and each column is assigned a specific data type, such as an integer number, a sequence of characters (for text), or a date. Each row in the table has a value for each column.

--

--

Parul Pandey
Analytics Vidhya

Principal Data Scientist @H2O.ai | Author of Machine Learning for High-Risk Applications