Skip to content

Commit 14f4422

Browse files
committed
Work with updated dataset
1 parent e916fcd commit 14f4422

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed
Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,44 @@
11
from datetime import datetime
2+
23
from config import app, db
3-
from models import Person, Note
4+
from models import Note, Person
45

56
PEOPLE_NOTES = [
67
{
78
"lname": "Fairy",
8-
"fname": "Sugar",
9+
"fname": "Tooth",
910
"notes": [
10-
("Cool, a mini-blogging application!", "2022-01-06 22:17:54"),
11-
("This could be useful", "2022-01-08 22:17:54"),
12-
("Well, sort of useful", "2022-03-06 22:17:54"),
11+
("I brush my teeth after each meal.", "2022-01-06 17:10:24"),
12+
(
13+
"The other day a friend said, I have big teeth.",
14+
"2022-03-05 22:17:54",
15+
),
16+
("Do you pay per gram?", "2022-03-05 22:18:10"),
1317
],
1418
},
1519
{
1620
"lname": "Ruprecht",
1721
"fname": "Knecht",
1822
"notes": [
1923
(
20-
"I'm going to make really profound observations",
21-
"2022-01-07 22:17:54",
24+
"I swear, I'll do better this year.",
25+
"2022-01-01 09:15:03",
2226
),
2327
(
24-
"Maybe they'll be more obvious than I thought",
25-
"2022-02-06 22:17:54",
28+
"Really! Only good deeds from now on!",
29+
"2022-02-06 13:09:21",
2630
),
2731
],
2832
},
2933
{
3034
"lname": "Bunny",
3135
"fname": "Easter",
3236
"notes": [
33-
("Has anyone seen my Easter eggs?", "2022-01-07 22:47:54"),
34-
("I'm really late delivering these!", "2022-04-06 22:17:54"),
37+
(
38+
"Please keep the current inflation rate in mind!",
39+
"2022-01-07 22:47:54",
40+
),
41+
("No need to hide the eggs this time.", "2022-04-06 13:03:17"),
3542
],
3643
},
3744
]
@@ -41,8 +48,7 @@
4148
db.create_all()
4249
for data in PEOPLE_NOTES:
4350
new_person = Person(lname=data.get("lname"), fname=data.get("fname"))
44-
for note in data.get("notes"):
45-
content, timestamp = note
51+
for content, timestamp in data.get("notes", []):
4652
new_person.notes.append(
4753
Note(
4854
content=content,
@@ -52,5 +58,4 @@
5258
)
5359
)
5460
db.session.add(new_person)
55-
5661
db.session.commit()

0 commit comments

Comments
 (0)