split the clip data into its own sheet

This commit is contained in:
Effie 2023-06-03 14:01:11 +10:00
parent 6a78b11a30
commit 2c069d9852
4 changed files with 8 additions and 3 deletions

View File

@ -11,6 +11,7 @@ with open('db.sql') as file:
db.executescript(file.read()) db.executescript(file.read())
data = pyexcel_odsr.get_data('reference.ods') data = pyexcel_odsr.get_data('reference.ods')
clipdata = pyexcel_odsr.get_data('reference_clips.ods')
# import song # import song
cur.executemany( cur.executemany(
@ -39,13 +40,13 @@ cur.executemany(
# import motif # import motif
cur.executemany( cur.executemany(
'insert into motif(id,name) values(?, ?)', 'insert into motif(id,name) values(?, ?)',
data['Motif'][1:] clipdata['Motif'][1:]
) )
# import clip # import clip
cur.executemany( cur.executemany(
'insert into clip(start_ms,duration_ms,song_id,motif_id) values (?, ?, ?, ?)', 'insert into clip(start_ms,duration_ms,song_id,motif_id) values (?, ?, ?, ?)',
data['Clip'][1:] clipdata['Clip'][1:]
) )
# import song x album # import song x album
@ -62,7 +63,11 @@ def creditparams(rows):
yield (row[0],artist,rows[0][index]) yield (row[0],artist,rows[0][index])
cur.executemany( 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']) creditparams(data['Song'])
) )

Binary file not shown.

BIN
reference_clips.ods Normal file

Binary file not shown.