# Python REST APIs With Flask, Connexion, and SQLAlchemy - Part 2

DevFeed: [Python REST APIs With Flask, Connexion, and SQLAlchemy - Part 2](<https://devfeed.tech/articles/python-rest-apis-with-flask-connexion-and-sqlalchemy-part-2-99147.md>)

Original publisher: [Read original article](<https://realpython.com/flask-connexion-rest-api-part-2/>)

Author: Philipp Acsany

Published: 2026-10-25T14:00:00Z

Content type: tutorial

Language: en

Sources: [Real Python](<https://devfeed.tech/sources/real-python.md>)

Topics: [REST API](<https://devfeed.tech/topics/rest-api.md>), [SQLAlchemy](<https://devfeed.tech/topics/sqlalchemy.md>), [Flask](<https://devfeed.tech/topics/flask.md>), [Python](<https://devfeed.tech/topics/python.md>), [rdbms](<https://devfeed.tech/topics/rdbms.md>), [Swagger](<https://devfeed.tech/topics/swagger.md>), [Query (disambiguation)](<https://devfeed.tech/topics/query.md>), [modules](<https://devfeed.tech/topics/modules.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [api-documentation](<https://devfeed.tech/tags/api-documentation.md>), [apis](<https://devfeed.tech/tags/apis.md>), [array](<https://devfeed.tech/tags/array.md>), [attack](<https://devfeed.tech/tags/attack.md>), [back-end](<https://devfeed.tech/tags/back-end.md>), [boolean](<https://devfeed.tech/tags/boolean.md>), [class](<https://devfeed.tech/tags/class.md>), [column](<https://devfeed.tech/tags/column.md>), [commit](<https://devfeed.tech/tags/commit.md>), [config](<https://devfeed.tech/tags/config.md>), [data](<https://devfeed.tech/tags/data.md>), [database](<https://devfeed.tech/tags/database.md>), [flask](<https://devfeed.tech/tags/flask.md>), [python](<https://devfeed.tech/tags/python.md>), [rest](<https://devfeed.tech/tags/rest.md>), [rest-api](<https://devfeed.tech/tags/rest-api.md>), [rest-apis](<https://devfeed.tech/tags/rest-apis.md>), [sqlalchemy](<https://devfeed.tech/tags/sqlalchemy.md>), [sqlite](<https://devfeed.tech/tags/sqlite.md>)

## AI overview

The tutorial replaces a Flask REST API's in-memory `PEOPLE` dictionary with a persistent SQLite database, while keeping the existing endpoints. It demonstrates direct `sqlite3` commands to create and query a `person` table, then explains how interpolating user input into SQL can enable injection attacks. It configures Flask-SQLAlchemy and models the table as a `Person` class with a unique last name, primary key, and UTC timestamps. Flask-Marshmallow schemas validate and convert between JSON and model objects. Updated handlers query, create, update, and delete database records; the home page reads from the database, and Swagger UI can exercise the API. The tutorial notes that SQLite stores the database in a single file and that data now persists across app restarts. The supplied text describes this second installment; adding related notes is reserved for part three.

## Source excerpt

Build a Flask REST API backed by a SQLite database. In part two of this series, you'll use SQLAlchemy and Marshmallow to persist and serialize data.