Posts Tagged: database
-
Flask-SQLAlchemy 3.1: Migrating from db.Model to Declarative Base Syntax
Flask-SQLAlchemy 3.1 migration db.Model DeclarativeBase Mapped mapped_column SQLAlchemy 2.0 Flask apps. Step-by-step convert legacy models to typed declarative mappings, Alembic compat, performance benefits, fix TypeErrors post-upgrade. Type hints IDE support future-proof.
-
How to Cache Flask-SQLAlchemy Queries with Redis for 5x Response Time Improvement
Learn how to implement Redis caching for Flask-SQLAlchemy queries to reduce database load and improve response times. This tutorial covers key hashing, TTL management, and invalidation strategies.
-
How to Test Flask Endpoints That Require Authentication Without Hitting the Database
Flask auth endpoint testing without DB: Mock Flask-Login user_loader, pytest fixtures for test_client + fake user. Parallel-safe (500 tests/s), zero flakes/DB setup. Full app+tests code. Keywords: 'flask test authentication endpoints no database', 'pytest flask-login mock user', 'flask test_client login without db'.
-
Using pytest Fixtures with FastAPI TestClient for Database Transaction Rollbacks
FastAPI pytest fixtures TestClient database transaction rollbacks: Isolate tests, zero data pollution. SQLAlchemy async sessions, pytest-asyncio override dependency. 500+ tests/s clean state. Code examples, conftest.py fixture, session.begin()/rollback(). Keywords: 'fastapi pytest database testing', 'fastapi testclient fixtures rollback', 'pytest fastapi sqlalchemy transaction rollback', 'fastapi testing isolation', 'pytest fixtures testclient'.