def model_to_json_test():
    from flask import jsonify
    q = db.session.query(WhiteSite).first()  # db = SQLAlchemy()
    q_dict = serialize(q)
    q_json = jsonify(q_dict)
    return q_json
 
 
def serialize(model):
    from sqlalchemy.orm import class_mapper
    columns = [c.key for c in class_mapper(model.__class__).columns]
    return dict((c, getattr(model, c)) for c in columns)
class WhiteSite(db.Model):
    __tablename__ = 'WHITE_SITE'
    site_name = db.Column(db.String(128), primary_key=True)
    comments = db.Column(db.String(1000))
    create_time = db.Column(db.DateTime, default=func.now())
    create_user = db.Column(db.String(128))
    last_modified_time = db.Column(db.DateTime, default=func.now(), onupdate=func.now())
    last_modified_user = db.Column(db.String(512))