summaryrefslogtreecommitdiff
path: root/scripts/populate/database.py
diff options
context:
space:
mode:
authorniliara-edu <nil.jimeno@estudiant.fjaverianas.com>2024-10-02 23:21:43 +0200
committerniliara-edu <nil.jimeno@estudiant.fjaverianas.com>2024-10-02 23:21:43 +0200
commit7df09f8b146ae7fb091787770fe5681381164f0e (patch)
tree0310d8dad1d0c6198d68d13b22030db3c5e8b28f /scripts/populate/database.py
parent0972fa6eab8c9111311f082ba8abfdc6b4a40945 (diff)
fix database setup
Diffstat (limited to 'scripts/populate/database.py')
-rw-r--r--scripts/populate/database.py18
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("""