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
From the course: Building RESTful APIs with Flask
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Adding an ORM (SQLAlchemy)3m 23s
-
(Locked)
Setting up SQLAlchemy4m 2s
-
(Locked)
Creating the ORM model classes6m 12s
-
(Locked)
Seeding the database with the Flask CLI8m 47s
-
(Locked)
Viewing the database in DB Browser for SQLite5m 8s
-
(Locked)
Retrieving a list of planets from the database6m 20s
-
(Locked)
Serializing SQLAlchemy results with Marshmallow8m 44s
-
-
-
-