Create Database and Table in SQLite

Creating and connecting to a database

First and foremost is to create a database for us to work with. Basically, database is a collection of tables, and there is no limit on number of tables we could have in our database.

Launch your python IDLE and create and save a new python file with name of your choice and location of your choice. Extract the script you see below from the course code you have downloaded from the first article and execute it by pressing F5

Below is the screen shot of my working code.

My working code

My working code

Above is the newly created database in my folder.

Code explanation

Create a table in our database

Now we are going to create a table inside our test database that is going to hold the information of students from different universities. Information will be Student name, University name, Country, Course, Age and Gender.

My code

Lets Code Image

Code explanation

In the next article we will discuss about how to add data to our table, update the data as well as delete the data in the table