|
1 | 1 | from datetime import datetime |
| 2 | + |
2 | 3 | from config import app, db |
3 | | -from models import Person, Note |
| 4 | +from models import Note, Person |
4 | 5 |
|
5 | 6 | PEOPLE_NOTES = [ |
6 | 7 | { |
7 | 8 | "lname": "Fairy", |
8 | | - "fname": "Sugar", |
| 9 | + "fname": "Tooth", |
9 | 10 | "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"), |
13 | 17 | ], |
14 | 18 | }, |
15 | 19 | { |
16 | 20 | "lname": "Ruprecht", |
17 | 21 | "fname": "Knecht", |
18 | 22 | "notes": [ |
19 | 23 | ( |
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", |
22 | 26 | ), |
23 | 27 | ( |
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", |
26 | 30 | ), |
27 | 31 | ], |
28 | 32 | }, |
29 | 33 | { |
30 | 34 | "lname": "Bunny", |
31 | 35 | "fname": "Easter", |
32 | 36 | "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"), |
35 | 42 | ], |
36 | 43 | }, |
37 | 44 | ] |
|
41 | 48 | db.create_all() |
42 | 49 | for data in PEOPLE_NOTES: |
43 | 50 | 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", []): |
46 | 52 | new_person.notes.append( |
47 | 53 | Note( |
48 | 54 | content=content, |
|
52 | 58 | ) |
53 | 59 | ) |
54 | 60 | db.session.add(new_person) |
55 | | - |
56 | 61 | db.session.commit() |
0 commit comments