-
Notifications
You must be signed in to change notification settings - Fork 0
/
populate.py
50 lines (42 loc) · 1.36 KB
/
populate.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
import sqlite3
import peewee
from models import Album, Artist
import datetime
def main():
new_artist = Artist.create(name="Newsboys")
new_album = Album(artist=new_artist,
title="Album title",
publisher="Sparrow",
release_date=datetime.date(1988, 12, 1),
media_type="CD",
)
new_album.save()
# batch save
albums = [{"artist": new_artist,
"title": "Hell is for Wimps",
"release_date": datetime.date(1990, 7, 31),
"publisher": "Sparrow",
"media_type": "CD"
},
{"artist": new_artist,
"title": "Love Liberty Disco",
"release_date": datetime.date(1999, 11, 16),
"publisher": "Sparrow",
"media_type": "CD"
},
{"artist": new_artist,
"title": "Thrive",
"release_date": datetime.date(2002, 3, 26),
"publisher": "Sparrow",
"media_type": "CD"}
]
for album in albums:
a = Album(**album)
a.save()
bands = ["MXPX", "Kutless", "Thousand Foot Krutch"]
for band in bands:
artist = Artist(name=band)
artist.save()
print("[+] done")
if __name__ == '__main__':
main()