Open a new terminal and run:
sqlite3 poems.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 poem (id INTEGER PRIMARY KEY, body TEXT, created_at timestamp);
Here we’re using SQL to create a table named “poem” with 3 columns:
id
an integer and also the primary keybody
for where we will store our poemcreated_at
for the date we created our poemThen exit sqlite:
.exit
You should now have a file named poems.db
alongside your app.py
file.
Please give a thumbs up or chat message when you’ve successfully created your poems database.
When we complete saving all data to the database the poem table will look something like this:
id | body | created_at |
---|---|---|
1 | This is just to say I have eaten the mandarines… | 2020-07-22 |
2 | This is just to say I have eaten the apples… | 2020-07-23 |
3 | This is just to say I have eaten the kumquats… | 2020-07-23 |