#!/usr/bin/env python # -*- encoding: utf-8 -*- ''' @Date:2022/07/18 15:21:25 ''' import uuid from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class ModelBase(object): fields = None def __init__(self): if not self.__class__.fields: self.__class__.fields = [x.key for x in self.__mapper__.attrs] def __iter__(self): if not self.__class__.fields: self.__class__.fields = [x.key for x in self.__mapper__.attrs] return next(self) def __next__(self): for key in self.__class__.fields: value = getattr(self, key) def get_uuid(): return str(uuid.uuid1()) def gen_id(): return uuid.uuid4().hex # if __name__ == '__main__': # print(type(gen_id)) # print(type(gen_id()))