# mitsuhiko/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/mitsuhiko-flask-sqlalchemy).**

4,311 stars · 907 forks · Python · BSD-3-Clause

## Links

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

## Description

Flask-SQLAlchemy is a relational database toolkit that integrates the SQLAlchemy object-relational mapper into web applications. It serves as a database session manager and schema toolkit, providing the necessary infrastructure to define data models and execute queries within a request lifecycle.

The project is distinguished by its multi-database routing engine, which uses bind-keys to map different models to multiple distinct database engines. It also includes a SQL query auditing tool that captures and logs executed statements and timing data for a single request to identify performance bottlenecks.

The toolkit covers comprehensive relational data modeling and schema management, including the ability to generate physical tables from metadata or reflect existing database structures. It manages connection lifecycles through request-scoped session management and provides utilities for query result pagination and transactional data modification.

## Tags

### Data & Databases

- [Object-Relational Mapping](https://awesome-repositories.com/f/data-databases/object-relational-mapping.md) — Provides a full object-relational mapper to bridge Python classes with relational database records. ([source](https://flask-sqlalchemy.palletsprojects.com/quickstart/))
- [Relational Database Toolkits](https://awesome-repositories.com/f/data-databases/relational-database-toolkits.md) — Provides a comprehensive set of helpers for schema definition, session management, and query execution in web apps.
- [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) — Uses a declarative class system to automatically manage database metadata and naming conventions. ([source](https://flask-sqlalchemy.palletsprojects.com/models/))
- [Transactional Updates](https://awesome-repositories.com/f/data-databases/data-update-apis/transactional-updates.md) — Ensures data consistency by grouping multiple record insertions, updates, and deletions into atomic transactional units. ([source](https://flask-sqlalchemy.palletsprojects.com/quickstart/))
- [Database Query Execution](https://awesome-repositories.com/f/data-databases/database-query-execution.md) — Manages the execution of SQL queries and data retrieval using a session-based flow. ([source](https://flask-sqlalchemy.palletsprojects.com/quickstart/))
- [Database Schema Generation](https://awesome-repositories.com/f/data-databases/database-schema-generation.md) — Automatically creates physical database tables based on declarative model definitions.
- [Object-Relational Mapping Models](https://awesome-repositories.com/f/data-databases/object-relational-mapping-models.md) — Implements a system for mapping application data structures to relational database table columns and types.
- [ORM Integrations](https://awesome-repositories.com/f/data-databases/orm-integrations.md) — Simplifies the integration of SQLAlchemy ORM with web application connection pools and configurations. ([source](https://cdn.jsdelivr.net/gh/mitsuhiko/flask-sqlalchemy@main/README.md))
- [Relational Data Modeling](https://awesome-repositories.com/f/data-databases/relational-data-modeling.md) — Provides tools for organizing data into structured tables and relationships using Python classes.
- [Database Session Lifecycles](https://awesome-repositories.com/f/data-databases/session-state-management/asynchronous-session-managers/database-session-lifecycles.md) — Automatically manages database connection lifecycles and transaction states within the scope of a web request.
- [Database Connection Configurations](https://awesome-repositories.com/f/data-databases/database-management-systems/database-systems-management/connection-transaction-management/database-connection-configurations.md) — Provides configuration for connection parameters like pool recycling and pre-pinging to maintain database stability. ([source](https://flask-sqlalchemy.palletsprojects.com/config/))
- [Multi-Bind Schema Management](https://awesome-repositories.com/f/data-databases/database-schema-managers/multi-bind-schema-management.md) — Coordinates schema creation and deletion across multiple configured database engines or specific bind subsets. ([source](https://flask-sqlalchemy.palletsprojects.com/binds/))
- [Model-Based Query Routing](https://awesome-repositories.com/f/data-databases/model-based-query-routing.md) — Provides a routing engine that maps specific ORM model classes to different database engine instances.
- [Multi-Database Connections](https://awesome-repositories.com/f/data-databases/multi-database-connections.md) — Coordinates multiple independent database connections within a single application runtime via unique keys. ([source](https://flask-sqlalchemy.palletsprojects.com/config/))
- [Paginated Results](https://awesome-repositories.com/f/data-databases/query-aggregates/paginated-results.md) — Splits large database result sets into smaller, numbered pages to optimize application performance. ([source](https://flask-sqlalchemy.palletsprojects.com/api/))
- [Custom Query Interface Methods](https://awesome-repositories.com/f/data-databases/query-interfaces/custom-query-interface-methods.md) — Allows extending the query object with custom methods to streamline specialized data retrieval for models. ([source](https://flask-sqlalchemy.palletsprojects.com/customizing/))
- [SQL Execution Logging](https://awesome-repositories.com/f/data-databases/sql-execution-logging.md) — Captures and logs executed SQL statements and timing data to identify performance bottlenecks.
- [SQLAlchemy Model Wrappers](https://awesome-repositories.com/f/data-databases/sqlalchemy-model-wrappers.md) — Provides a wrapper for declarative models that simplifies table creation and record retrieval with integrated error handling.

### Networking & Communication

- [Connection Management](https://awesome-repositories.com/f/networking-communication/database-connection-pooling/connection-management.md) — Manages engine setup and model associations while automatically cleaning up connections and sessions after every request. ([source](https://flask-sqlalchemy.palletsprojects.com/api/))
- [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 session lifecycles to the active web request context to ensure automatic connection cleanup.

### Software Engineering & Architecture

- [Multi-Database Routing](https://awesome-repositories.com/f/software-engineering-architecture/multi-database-routing.md) — Implements architectural routing of model queries to multiple distinct database engines using bind-keys.
- [Database Schema Reflection](https://awesome-repositories.com/f/software-engineering-architecture/reflection-utilities/database-schema-reflection.md) — Detects the structure of existing databases to automatically generate corresponding application-level table objects.
- [Database Table Generators](https://awesome-repositories.com/f/software-engineering-architecture/schema-driven-generators/database-table-generators.md) — Automatically produces physical database tables by interpreting metadata defined in declarative class definitions.

### System Administration & Monitoring

- [Application-Context Session Scoping](https://awesome-repositories.com/f/system-administration-monitoring/database-session-management/application-context-session-scoping.md) — Restricts database session scoping to the active application context to ensure connections close automatically. ([source](https://flask-sqlalchemy.palletsprojects.com/contexts/))
- [Query Logging](https://awesome-repositories.com/f/system-administration-monitoring/query-logging.md) — Tracks executed SQL statements and timing data during requests to facilitate performance monitoring and debugging. ([source](https://flask-sqlalchemy.palletsprojects.com/record-queries/))

### Web Development

- [SQLAlchemy Integrations](https://awesome-repositories.com/f/web-development/sqlalchemy-integrations.md) — Integrates SQLAlchemy ORM capabilities directly into the Flask web framework for model and connection management.

### Programming Languages & Runtimes

- [Database Model Mixins](https://awesome-repositories.com/f/programming-languages-runtimes/class-inheritance/database-model-mixins.md) — Supports extending base classes or using mixins to share common attributes and logic across database models. ([source](https://flask-sqlalchemy.palletsprojects.com/customizing/))

### Part of an Awesome List

- [Data Management](https://awesome-repositories.com/f/awesome-lists/data/data-management.md) — Adds SQLAlchemy support to Flask.
