From the course: Building RESTful APIs with Flask

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Serializing SQLAlchemy results with Marshmallow

Serializing SQLAlchemy results with Marshmallow

From the course: Building RESTful APIs with Flask

Start my 1-month free trial

Serializing SQLAlchemy results with Marshmallow

- [Instructor] The process of converting an object into a textual representation of that object is called serialization. The process of converting the text back into an object is called deserialization. We need to figure out how to serialize a collection of SQLAlchemy data rows. The best answer I think is to use a third-party library since one already exists specifically for this purpose. If you go into PyPy at PyPy.org, you can do a search on Marshmallow, specifically Flask-Marshmallow. Marshmallow is a serialization library for Python and naturally somebody came along and made a Flask variate that depends on it. And we can see in the project description that it's an integration layer for Flask and Marshmallow and we can see that it automatically or is well designed to integrate with Flask SQLAlchemy which is what we're using. If you want documentation and sample code, there is a web page for it. You can find it at https://flask-marshmallow.readthedocs.io. And since I'm working in…

Contents