def fetch_all(self, ds_id): cursor = LabelEntity.select().where(LabelEntity.dataset == ds_id).dicts().execute() result = [] for ds in list(cursor): vo = LabelVO() result.append(vo) for k, v in ds.items(): setattr(vo, k, v) return result
def find_by_name(self, ds_id, label_name): query = ( LabelEntity.select().where((LabelEntity.dataset == ds_id) & (LabelEntity.name == label_name))) # print(query) cursor = query.dicts().execute() result = list(cursor) vo = LabelVO() if len(result) > 0: row = result[0] for k, v in row.items(): setattr(vo, k, v) return vo return None