def init_genres(): g_list = [] Genres.__table__.drop(engine) Genres.__table__.create(engine) for k, v in genres_dict.items(): g_list.append(Genres(name=k, path=v)) session = DBSession() session.add_all(g_list) session.commit() session.close()
async def addMovie(): see = DBSession() print("start --- add move") await asyncio.sleep(2) see.add_all(mvList) see.commit() see.close() # for mv in mvList: # print("add-->", mv) print("end --- add move--end") checkSame()
def import_all_video(value): movieList = [] # ['编号', '影片名称', '英文名称', '集数', '影片类型', '导演', '演员', '子标题', '影片描述', '片源'] ob_id = '@{}!{}'.format(value[1], value[5]) source = value[9] mv = Video(title_cn=value[1], title_en=value[2], total=int(value[3]), g_path=genres_dict.get(value[4]), director=value[5], actors=value[6], subtitle=value[7], desc=value[8], obtain_id=ob_id) mv.sources = parse_source_to_list(source, ob_id) # print("insert-->", mv) movieList.append(mv) se = DBSession() se.add_all(movieList) se.commit() se.close()