diff --git a/build_db.py b/build_db.py index c78e0da..82bdcea 100644 --- a/build_db.py +++ b/build_db.py @@ -12,13 +12,10 @@ with open('db.sql') as file: data = pyexcel_odsr.get_data('reference.ods') -def nullifempty(cell): - return None if len(cell)==0 else cell - # import song cur.executemany( 'insert or ignore into song(id,name,name_jp) values(?, ?, ?)', - ((row[0],row[3],None if len(row)<5 else nullifempty(row[4])) for row in data['Song'][1:]) + ((row[0],row[3],row[4]) for row in data['Song'][1:]) ) # import album @@ -30,7 +27,7 @@ cur.executemany( # import artist cur.executemany( 'insert into artist(id,name_rm,name) values(?, ?, ?)', - ((row[0],nullifempty(row[1]),row[2]) for row in data['Artist'][1:]) + ((row[0],row[1],row[2]) for row in data['Artist'][1:]) ) # import credit @@ -63,8 +60,6 @@ cur.executemany( creditparams(data['Song']) ) -# import song x album -# "insert into song_album(album_id,track,song_id) values (?, ?, (select id from song where name = ? and coalesce(name_jp,'') = coalesce(?,'')))" cur.executemany( "insert into song_album(song_id,album_id,track) values (?, ?, ?)", ((row[0],row[1],row[2]) for row in data['Song'][1:])