diff --git a/build_db.py b/build_db.py index 086113d..07e46bf 100644 --- a/build_db.py +++ b/build_db.py @@ -11,6 +11,7 @@ with open('db.sql') as file: db.executescript(file.read()) data = pyexcel_odsr.get_data('reference.ods') +clipdata = pyexcel_odsr.get_data('reference_clips.ods') # import song cur.executemany( @@ -39,13 +40,13 @@ cur.executemany( # import motif cur.executemany( 'insert into motif(id,name) values(?, ?)', - data['Motif'][1:] + clipdata['Motif'][1:] ) # import clip cur.executemany( 'insert into clip(start_ms,duration_ms,song_id,motif_id) values (?, ?, ?, ?)', - data['Clip'][1:] + clipdata['Clip'][1:] ) # import song x album @@ -62,7 +63,11 @@ def creditparams(rows): yield (row[0],artist,rows[0][index]) cur.executemany( - 'insert or ignore into song_artist(song_id,artist_id,credit_id) values (?, (select id from artist where coalesce(nullif(name_rm,''),name) = ?), (select id from credit where name = ?))', + '''insert or ignore into song_artist(song_id,artist_id,credit_id) + values ( + ?, + (select id from artist where coalesce(nullif(name_rm,''),name) = ?), + (select id from credit where name = ?))''', creditparams(data['Song']) ) diff --git a/generate.py b/build_pages.py similarity index 100% rename from generate.py rename to build_pages.py diff --git a/reference.ods b/reference.ods index 0df0eb2..d23a999 100644 Binary files a/reference.ods and b/reference.ods differ diff --git a/reference_clips.ods b/reference_clips.ods new file mode 100644 index 0000000..cc11f87 Binary files /dev/null and b/reference_clips.ods differ