Serialization with Python & Flask-SQLAlchemy

Publicado el: 30 junio 2023
en el canal de: Dan's Tutorials
614
11

copy and paste scripts:

Get field names:
[col.name for col in Table.__table__.columns]

Serialize a table (convert it to a JSON (python dictionary) by converting each record to a list that contains a dictionary holding key:value pairs of the field name and the data the cell holds eg. Table = [{id: 1, "name": "James", "dob": "1/2/2023", "age": 190}, {id: 2, "name": "Batholomew", "dob": "35/2/1066", "age": -9}]):
with app.app_context(): [{col.name: getattr(record, col) for col in Table.__table__.columns} for record in Table.query.all()]


En esta página del sitio puede ver el video en línea Serialization with Python & Flask-SQLAlchemy de Duración hora minuto segunda en buena calidad , que subió el usuario Dan's Tutorials 30 junio 2023, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 614 veces y le gustó 11 a los espectadores. Disfruta viendo!