diff --git a/app.py b/app.py index e8d1ddf..5433fc3 100644 --- a/app.py +++ b/app.py @@ -8,6 +8,8 @@ def songpage(id): db = sqlite3.connect("file:songbook.sqlite?mode=ro", uri=True) + # query song name + name, = db.execute(''' select name @@ -23,7 +25,7 @@ def songpage(id): album_info = db.execute(''' select - album_id, track, album.name, album.code + track, album.name, album.code from song_album join @@ -36,8 +38,48 @@ def songpage(id): (id,) ).fetchall() + # query artist info + + artist_info = db.execute(''' + select + artist.name, artist.name_rm, credit.name + from + song_artist + join + artist + on + song_artist.artist_id=artist.id + join + credit + on + song_artist.credit_id=credit.id + where + song_id = ? + ''', + (id,) + ).fetchall() + + # query clip info + + clip_info = db.execute(''' + select + song_id, motif_id, motif.name + from + clip + join + motif + on + clip.motif_id=motif.id + where + song_id = ? + ''', + (id,) + ).fetchall() + return flask.render_template('song.jinja', name=name, id=id, - album_info=album_info + album_info=album_info, + clip_info=clip_info, + artist_info=artist_info ) \ No newline at end of file diff --git a/build_db.py b/build_db.py index 737402f..a95db16 100644 --- a/build_db.py +++ b/build_db.py @@ -37,6 +37,8 @@ cur.executemany( data['Credit'][1:] ) +print(clipdata['Motif'][1:]) + # import motif cur.executemany( 'insert into motif(id,name) values(?, ?)', diff --git a/reference_clips.ods b/reference_clips.ods index 219c1af..7ff38b8 100644 Binary files a/reference_clips.ods and b/reference_clips.ods differ diff --git a/templates/song.jinja b/templates/song.jinja index fb57ddb..6e65366 100644 --- a/templates/song.jinja +++ b/templates/song.jinja @@ -2,19 +2,36 @@ {% block title %}{{ name }}{% endblock %} {% block content %} -
Artist:
+Album:
blah
+Clips:
- +