import collections def get_dict_list(key,value_list): """把一个列表的数据变成有序字典 :param key [] :param value_list [[]] :return [{},{}] """ data_list=[] for i in value_list: data_list.append(collections.OrderedDict(zip(key, i))) return data_list def get_round(li,p=4): """ :param li: [[]] or [()] :return: [[]] """ y=[] for i in li: x = [] for j in i: if isinstance(j,float): x.append(round(j,p)) else: x.append(j) y.append(x) return y def getLimitData(DataBase,sql,page,page_size): total = DataBase.getData(f"select count(1) from ({sql}) a")[0][0] if page and page_size: sql += f" limit {(page - 1) * page_size},{page_size} " print(sql) data = DataBase.getData_json(sql) return data,total def getLimitSumData(DataBase,sql,sumSql,page,page_size): data,total= getLimitData(DataBase,sql,page,page_size) di =DataBase.getData_json(sumSql)[0] return data,total,di