Answers for "SQLAlchemy Users to JSON code snippet"

0

SQLAlchemy Users to JSON code snippet

@app.route('/results/')
def results():
    cols = ['id', 'url', 'shipping']
    data = Table.query.all()
    result = [{col: getattr(d, col) for col in cols} for d in data]
    return jsonify(result=result)
Posted by: Guest on September-21-2021
0

SQLAlchemy Users to JSON code snippet

@app.route('/results/')
def results():
    data = Table.query.all()
    result = [d.__dict__ for d in data]
    return jsonify(result=result)
Posted by: Guest on September-21-2021

Python Answers by Framework

Browse Popular Code Answers by Language