diff options
Diffstat (limited to 'scripts/populate/database.py')
-rw-r--r-- | scripts/populate/database.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/scripts/populate/database.py b/scripts/populate/database.py index 2319812..eaccfd2 100644 --- a/scripts/populate/database.py +++ b/scripts/populate/database.py @@ -16,19 +16,17 @@ connector = mysql.connector.connect( cursor = connector.cursor() - - def process_albums(album_list): [process_album(album, album_id) for album_id, album in enumerate(album_list, 1)] def process_album(album, album_id): - upload_album(album) + upload_album(album, album_id) [upload_song(song, album_id) for song in album.songs] -def upload_album(album): +def upload_album(album, album_id): album.name = album.name.lower() cursor.execute(""" INSERT INTO album ( @@ -40,9 +38,19 @@ def upload_album(album): """, { 'name': album.name, 'cover': album.cover, - 'artist_id': album.artist + 'artist_id': album.artist, }) + if album.release: + cursor.execute(""" + UPDATE album + SET release_date = (%(release)s) + WHERE id = %(album_id)s; + """, { + 'release': album.release, + 'album_id': album_id, + }) + def upload_song(song, album_id): cursor.execute(""" |