model_util.py 232 B

12345678910
  1. def to_dict(model):
  2. return {c.name: getattr(model, c.name, None) for c in model.__table__.columns}
  3. def to_list(models: list):
  4. return [to_dict(model) for model in models]
  5. def to_str(model):
  6. return str(to_dict(model))