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.
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 talkdescription
where we will store a description for our talkcreated_at
for the date we created the talkThen exit sqlite:
.exit
You should now have a file named talks.db
alongside your app.py
file.
Please give a thumbs up or chat message when you’ve successfully created your talks database.
When we complete saving all data to the database the talk table will look something like this:
id | title | description | created_at |
---|---|---|---|
1 | Talk title 1 | This is a description for talk 1 | 2021-07-22 |
2 | Talk title 2 | This is a description for talk 2 | 2021-07-23 |
3 | Talk title 3 | This is a description for talk 3 | 2021-07-23 |