/
db_init_tables.py
executable file
·123 lines (97 loc) · 4.71 KB
/
db_init_tables.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!flask/bin/python
from app import db
from app.models import ReadingLevels, BookGenre, Volunteer, Person, Donor, CashInventory, Author, BookDetails, BookInventory, Client
def init_persons():
Person.generate_fake(100)
Donor.generate_fake()
Volunteer.generate_fake()
def init_funds():
funds = CashInventory(funds=500)
db.session.add(funds)
db.session.commit()
def init_books():
Author.generate_fake()
BookDetails.generate_fake()
BookInventory.generate_fake()
def init_clients():
child = ReadingLevels(reading_level='Children')
teen = ReadingLevels(reading_level='Teen')
adult = ReadingLevels(reading_level='Adult')
db.session.add(child)
db.session.add(teen)
db.session.add(adult)
db.session.commit()
#Client.generate_fake()
def init_genre():
if BookGenre.query.count() == 0:
book_genre = BookGenre()
book_genre.genre = "Autobiography"
book_genre.genre_description = "Ready to read how proud someone is of themselves? Then you've come to the right place!"
db.session.add(book_genre)
book_genre = BookGenre()
book_genre.genre = "Biography"
book_genre.genre_description = "When being self-obsessed isn't enough, why not read all about the intimate details of someone else?"
db.session.add(book_genre)
book_genre = BookGenre()
book_genre.genre = "Comic"
book_genre.genre_description = "Re-live your childhood years by reading graphic about superheros, or just every day life in this interesting art medium."
db.session.add(book_genre)
book_genre = BookGenre()
book_genre.genre = "Crime/Detective"
book_genre.genre_description = "Who killed Mrs. Peabody? Was it the butler? The maid? Some rich person that's bored (i.e. the rest of the house)? You'll have to read to find out!"
db.session.add(book_genre)
book_genre = BookGenre()
book_genre.genre = "Fantasy"
book_genre.genre_description = "When the real world isn't enough, escape to a far off land of complicated names that somehow always serves as a reflection of mankind."
db.session.add(book_genre)
book_genre = BookGenre()
book_genre.genre = "Historical Fiction"
book_genre.genre_description = "Ever wondered, \"Wouldn't it be cool if someone wrote a story of what it was like living in <insert period author didn't live during>\"? So did these authors apparently."
db.session.add(book_genre)
book_genre = BookGenre()
book_genre.genre = "Magical Realism"
book_genre.genre_description = "Also known as Realismo Magico, these stories depict what happens when the gentle hand of fate puts everything 'just right' for something magical to happen"
db.session.add(book_genre)
book_genre = BookGenre()
book_genre.genre = "Mystery"
book_genre.genre_description = "Not really sure how this is different from crime, but it's suspenseful nonetheless!"
db.session.add(book_genre)
book_genre = BookGenre()
book_genre.genre = "Mythopoeia"
book_genre.genre_description = "I don't actually know what this is but I imagine it is a mix of myth and something else. I'd buy a book--It sounds interesting!"
db.session.add(book_genre)
book_genre = BookGenre()
book_genre.genre = "Poetry"
book_genre.genre_description = "When life is too convoluted, why not spend time seeing how poets distill our complicated world into just a few lines?"
db.session.add(book_genre)
book_genre = BookGenre()
book_genre.genre = "Realistic Fiction"
book_genre.genre_description = "It's fiction, but it seems real! In other words, it's almost everything other than fantasy or folklore."
db.session.add(book_genre)
book_genre = BookGenre()
book_genre.genre = "Scientific Fiction"
book_genre.genre_description = "Ever thought it would be really cool to do something impossible? In the world of SciFi, something is only impossible if you say it is."
db.session.add(book_genre)
book_genre = BookGenre()
book_genre.genre = "Short Story"
book_genre.genre_description = "Not interested in a big commitment? Read a short story and leave with one or two interesting thoughts!"
db.session.add(book_genre)
book_genre = BookGenre()
book_genre.genre = "Textbook"
book_genre.genre_description = "Oh come on, who wants to actually learn? Go get a SciFi book!"
db.session.add(book_genre)
book_genre = BookGenre()
book_genre.genre = "Thriller"
book_genre.genre_description = "These short novels are just exciting enough to capture your attention until the book is finished, but they are quickly forgotten. So sad."
db.session.add(book_genre)
book_genre = BookGenre()
book_genre.genre = "Western"
book_genre.genre_description = "Re-live the glamorized west during the settlement of the Great Frontier!"
db.session.add(book_genre)
db.session.commit()
if __name__ == '__main__':
init_genre()
init_funds()
#init_persons()
init_clients()
#init_books()