Create Database

Create Database File

Open a new terminal and run: sqlite3 talks.db

This will create a new, empty sqlite database. In the case of sqlite this is just a file alongside your other files for this project.

Create Database Structure

In the sqlite prompt enter:

CREATE TABLE talk (id INTEGER PRIMARY KEY, title TEXT, description TEXT, created_at timestamp);

Here we’re using SQL to create a table named “talk” with 4 columns:

  • id an integer and also the primary key (a unique identifier for the record of the talk in the database)
  • body for where we will store the title of our talk
  • description where we will store a description for our talk
  • created_at for the date we created the talk

Then exit sqlite: .exit

You should now have a file named talks.db alongside your app.py file.

When we complete saving all data to the database the talk table will look something like this:

idtitledescriptioncreated_at
1Talk title 1This is a description for talk 12021-07-22
2Talk title 2This is a description for talk 22021-07-23
3Talk title 3This is a description for talk 32021-07-23