# pallets-eco/flask-sqlalchemy

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/pallets-eco-flask-sqlalchemy).**

4,314 stars · 908 forks · Python · BSD-3-Clause

## Links

- GitHub: https://github.com/pallets-eco/flask-sqlalchemy
- Homepage: https://flask-sqlalchemy.readthedocs.io
- awesome-repositories: https://awesome-repositories.com/repository/pallets-eco-flask-sqlalchemy.md

## Topics

`flask` `flask-sqlalchemy` `python` `sqlalchemy`

## Description

Flask-SQLAlchemy is a toolkit that integrates the SQLAlchemy relational database toolkit with the Flask web framework. It enables relational data modeling by defining database table structures as Python classes and manages the persistence and retrieval of database records within a web application.

The project binds database session lifecycles to the active application request context to ensure automatic connection cleanup. It provides specialized utilities for web data access, including query result pagination and a mechanism to automatically trigger 404 Not Found responses when a requested database record is missing.

The extension covers a broad range of database management capabilities, including declarative model mapping, schema reflection, and the generation of physical table structures. It supports advanced connection management through multi-bind query routing and provides observability tools for auditing SQL query performance and execution timing.

## Tags

### Data & Databases

- [ORM Model Declarations](https://awesome-repositories.com/f/data-databases/data-structure-definitions/data-class-generators/kotlin-data-class-declarations/python-data-class-declarations/orm-model-declarations.md) — Creates table structures using declarative classes that map application objects to database rows. ([source](https://flask-sqlalchemy.readthedocs.io/models/))
- [Database Connection Configurations](https://awesome-repositories.com/f/data-databases/database-connection-configurations.md) — Provides support for defining connection URIs and engine options for primary and secondary data stores. ([source](https://flask-sqlalchemy.readthedocs.io/config/))
- [Database Query Execution](https://awesome-repositories.com/f/data-databases/database-query-execution.md) — Runs selection queries to retrieve specific records or collections of data from the database. ([source](https://flask-sqlalchemy.readthedocs.io/quickstart/))
- [Record Creations and Updates](https://awesome-repositories.com/f/data-databases/database-record-management/record-updates/record-creations-and-updates.md) — Performs create, update, and delete operations on model objects and persists changes through a session. ([source](https://flask-sqlalchemy.readthedocs.io/queries/))
- [Relational Data Modeling](https://awesome-repositories.com/f/data-databases/relational-data-modeling.md) — Defines database table structures as Python classes to map application objects to relational database rows.
- [Database Session Lifecycles](https://awesome-repositories.com/f/data-databases/session-state-management/asynchronous-session-managers/database-session-lifecycles.md) — Automatically manages database connection and transaction lifecycles within the scope of a web request.
- [Multi-Bind Schema Management](https://awesome-repositories.com/f/data-databases/database-schema-managers/multi-bind-schema-management.md) — Enables creating or dropping tables across all configured database connections or targeting a specific subset. ([source](https://flask-sqlalchemy.readthedocs.io/binds/))
- [Database Table Generation](https://awesome-repositories.com/f/data-databases/database-table-generation.md) — Provides utilities to automatically generate physical database table structures from defined model classes. ([source](https://flask-sqlalchemy.readthedocs.io/models/))
- [Model-Based Query Routing](https://awesome-repositories.com/f/data-databases/model-based-query-routing.md) — Directs database queries to specific data stores by associating model classes with designated database engines.
- [Paginated Results](https://awesome-repositories.com/f/data-databases/query-aggregates/paginated-results.md) — Splits large datasets into numbered chunks with metadata for request-parameter based navigation. ([source](https://flask-sqlalchemy.readthedocs.io/api/))
- [Custom Query Interface Methods](https://awesome-repositories.com/f/data-databases/query-interfaces/custom-query-interface-methods.md) — Supports adding custom methods to the query interface globally or on a per-model basis. ([source](https://flask-sqlalchemy.readthedocs.io/customizing/))
- [Query Performance Monitors](https://awesome-repositories.com/f/data-databases/query-performance-monitors.md) — Records SQL execution time and application location for every query to identify performance bottlenecks. ([source](https://flask-sqlalchemy.readthedocs.io/record-queries/))
- [Single Record Retrievers](https://awesome-repositories.com/f/data-databases/single-record-retrievers.md) — Provides a utility to retrieve a single database record or automatically trigger a 404 Not Found response. ([source](https://flask-sqlalchemy.readthedocs.io/api/))
- [SQL Query Debuggers](https://awesome-repositories.com/f/data-databases/sql-query-editors/sql-query-debuggers.md) — Provides tools for monitoring executed SQL statements and recording performance metadata to identify bottlenecks.
- [Model-Engine Routing](https://awesome-repositories.com/f/data-databases/virtual-table-querying/model-engine-routing.md) — Maps specific models or tables to different database engines to manage data across distinct stores. ([source](https://flask-sqlalchemy.readthedocs.io/binds/))

### Web Development

- [Flask Integrations](https://awesome-repositories.com/f/web-development/flask-integrations.md) — Integrates the SQLAlchemy relational database toolkit with the Flask web framework for data persistence.
- [Web Data Access Utilities](https://awesome-repositories.com/f/web-development/web-data-access-utilities.md) — Implements specialized utilities for web data access, including query pagination and automatic 404 responses for missing records.

### Networking & Communication

- [Request-Bound Session Management](https://awesome-repositories.com/f/networking-communication/network-reliability-diagnostics/connection-session-management/connection-management/connection-lifecycle-managers/session-lifecycle-management/request-bound-session-management.md) — Binds database sessions to the active application request lifecycle to ensure automatic connection cleanup after responses.
- [Database Connection Pooling](https://awesome-repositories.com/f/networking-communication/database-connection-pooling.md) — Manages a pool of database connections with recycling and pre-ping checks to maintain stability across HTTP requests.
- [Connection Stability Features](https://awesome-repositories.com/f/networking-communication/network-transport-protocols/tcp-connection-pooling/tcp-server-management/connection-stability-features.md) — Prevents connection timeouts and handles disconnects using pool recycling and pre-ping checks. ([source](https://flask-sqlalchemy.readthedocs.io/config/))

### System Administration & Monitoring

- [Application-Context Session Scoping](https://awesome-repositories.com/f/system-administration-monitoring/database-session-management/application-context-session-scoping.md) — Binds database sessions to the active application context for automatic connection cleanup. ([source](https://flask-sqlalchemy.readthedocs.io/contexts/))

### Software Engineering & Architecture

- [Database Schema Reflection](https://awesome-repositories.com/f/software-engineering-architecture/reflection-utilities/database-schema-reflection.md) — Inspects existing database structures at runtime to automatically generate application-level metadata and models.
