Update row (SQLAlchemy) with data from marshmallow

UPDATED, 2022-12-08

Extending the ModelSchema from marshmallow-sqlalchemy instead of Flask-Marshmallow you can use the load method, which is defined like this:

load(data, *, session=None, instance=None, transient=False, **kwargs)

Putting that to use, it should look like that (or similar query):

node_schema.load(json_data, session= current_app.session, instance=Node().query.get(node_id))

And if you want to load without all required fields of Model, you can add the partial=True argument, like this:

node_schema.load(json_data, instance=Node().query.get(node_id), partial=True)

See the docs for more info (does not include definition of ModelSchema.load).
See the code for the load definition.

Leave a Comment

tech