def query_group_page_data_by_path(path, page, page_length): result_array = [] session = DBSession() total_count = session.query(Video).filter(Video.g_path == path).count() start = int(int(page) * int(page_length)) end = int(start + page_length) print('page,page_lenth,start,end,total_count',page,page_length,start,end,total_count) selet_cl = [Video.id, Video.title_cn, Video.title_en, Video.g_path, Video.poster, Video.subtitle, Video.actors, Video.director, Video.total, Video.obtain_id] var = session.query().with_entities(Video.id, Video.title_cn, Video.title_en, Video.g_path, Video.poster, Video.subtitle, Video.actors, Video.director, Video.total, Video.obtain_id).filter( Video.g_path == path).slice(start, end).all() for v in var: item_dict = {} for idx, val in enumerate(v): item_dict[selet_cl[idx].name] = val print(path, v) result_array.append(item_dict) session.commit() print('result_array==', result_array) session.close() return result_array, int(total_count)
def checkSame(): see = DBSession() mv4 = Video(title_cn='wo shi 4') mv5 = Video(title_cn='wo shi 1') see.add(mv4) print('same-->mv4===', mv4) see.query(mv5) outUser = see.query(Video).filter_by(title_cn='wo shi 4').first() outUser2 = see.query(Video).filter_by(title_cn='wo shi 1').first() print('same-->out===', outUser) print('same-->', mv5 is outUser2) see.commit() see.close()
def query_video_first(): session = DBSession() var = session.query(Video).first() print('first', var) session.commit() session.close() return var
def query_video_all(): session = DBSession() var = session.query(Video).all() print('all size()->', len(var)) session.commit() session.close() return var
def query_detail_video_by_obtain_id(obtain_id): session = DBSession() var = session.query(Video).filter(Video.obtain_id == obtain_id).first() print('first', var) session.commit() # session.close() return var
def query_video_all_movie(type): session = DBSession() var = session.query(Video).filter(Video.g_path == genres_dict.get(type)) for v in var: print(type, v) session.commit() session.close() return var
def query_video_by_path_and_limit(g_path, count): session = DBSession() var = session.query(Video).filter(Video.g_path == g_path).limit(count).all() for v in var: print(g_path, v) session.commit() print('query_video_by_path_and_limit==', var) # session.close() return var
def query_video_by_type_and_limit(typename, count): session = DBSession() var = session.query(Video).filter(Video.g_path == genres_dict.get(typename)).limit(count).all() for v in var: print(typename, v) session.commit() print('sr==', var) # session.close() return var
def query_all_genres(): res = [] session = DBSession() var = session.query(Genres).all() for v in var: print("genres query:", v) res.append(v._asdict()) session.commit() session.close() return res
def query_video_index(index): logging.info('query_video_index:{}'.format("logging.info")) session = DBSession() var = session.query(Video).filter(Video.g_path == genres_dict.get('电视剧')).limit(index) for v in var: print('\n') logging.info('query_video_index:{}'.format(v)) session.commit() session.close() return var
def query_recommend_video_by_path(path, length): result_array = [] session = DBSession() selet_cl = [Video.id, Video.title_cn, Video.title_en, Video.g_path, Video.poster, Video.subtitle, Video.actors, Video.director, Video.total, Video.obtain_id] var = session.query().with_entities(Video.id, Video.title_cn, Video.title_en, Video.g_path, Video.poster, Video.subtitle, Video.actors, Video.director, Video.total, Video.obtain_id).filter( Video.g_path == path).limit(length).all() for v in var: item_dict = {} for idx, val in enumerate(v): item_dict[selet_cl[idx].name] = val print(path, v) result_array.append(item_dict) session.commit() print('sr==', var) session.close() return result_array