split the clip data into its own sheet
This commit is contained in:
parent
6a78b11a30
commit
2c069d9852
11
build_db.py
11
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'])
|
||||
)
|
||||
|
||||
|
||||
BIN
reference.ods
BIN
reference.ods
Binary file not shown.
BIN
reference_clips.ods
Normal file
BIN
reference_clips.ods
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user