The final chapter of 'SQLAlchemy 2 in Practice' covers integrating SQLAlchemy with Python web frameworks. It demonstrates two complete integration examples using Flask and FastAPI, covering key topics like namespacing SQLAlchemy imports, model serialization to JSON via to_dict() methods, and the Alchemical helper package. A practical example builds a paginated, sortable, searchable orders table with a grid.js frontend, showing how to construct dynamic queries with filtering, sorting, and pagination in a framework-agnostic queries module. Both synchronous (Flask) and asynchronous (FastAPI) implementations are provided with full project structure, Alembic migration setup, and deployment guidance.

28m read timeFrom blog.miguelgrinberg.com
Post cover image
Table of contents
General Integration ApproachSQLAlchemy Integration TechniquesAn Example Web ApplicationA Last Word

Sort: