def get_by_id(id_: int, cook=True): value = DBUtils.get_by_single("music", "id", id_) # 转换成music对象 if cook and value is not None: m = Converter.local_data_local_music(value) return m return value
def get_by_name(name, cook=True): value = DBUtils.get_by_single("music", "name", name) # 转换成music对象 if cook and value is not None: m = Converter.local_data_local_music(value) return m return value
def get_by_music_id(music_id: str, cook=True): value = DBUtils.get_by_single("music", "music_id", music_id) # 转换成music对象 if cook and value is not None: m = Converter.local_data_local_music(value) return m return value
def get_all(cook=True): cursor = DBUtils.get_cursor() cursor.execute("select * from music") values = cursor.fetchall() cursor.close() # 转换成music对象 if cook: musics = [] for v in values: m = Converter.local_data_local_music(v) musics.append(m) return musics return values