def groups_to_model(self, groups): data = self.prepare_json_from(groups) groups = [] for groupJson in data: group = Group() group.id = int(groupJson['id']) group.name = groupJson['name'] group.faculty = groupJson['faculty'] groups.append(group) return groups
def create_group(name, label): """ 设置用户分组 :param name: :param label: :return: """ with db.auto_commit(): group = Group() group.name = name group.label = label db.session.add(group) print("成功创建用户分组:%s " % (name, ))