remove 'nullifempty'
This commit is contained in:
parent
6585844e03
commit
8025391655
@ -12,13 +12,10 @@ with open('db.sql') as file:
|
|||||||
|
|
||||||
data = pyexcel_odsr.get_data('reference.ods')
|
data = pyexcel_odsr.get_data('reference.ods')
|
||||||
|
|
||||||
def nullifempty(cell):
|
|
||||||
return None if len(cell)==0 else cell
|
|
||||||
|
|
||||||
# import song
|
# import song
|
||||||
cur.executemany(
|
cur.executemany(
|
||||||
'insert or ignore into song(id,name,name_jp) values(?, ?, ?)',
|
'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
|
# import album
|
||||||
@ -30,7 +27,7 @@ cur.executemany(
|
|||||||
# import artist
|
# import artist
|
||||||
cur.executemany(
|
cur.executemany(
|
||||||
'insert into artist(id,name_rm,name) values(?, ?, ?)',
|
'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
|
# import credit
|
||||||
@ -63,8 +60,6 @@ cur.executemany(
|
|||||||
creditparams(data['Song'])
|
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(
|
cur.executemany(
|
||||||
"insert into song_album(song_id,album_id,track) values (?, ?, ?)",
|
"insert into song_album(song_id,album_id,track) values (?, ?, ?)",
|
||||||
((row[0],row[1],row[2]) for row in data['Song'][1:])
|
((row[0],row[1],row[2]) for row in data['Song'][1:])
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user