feat(api): migracion completa de Flask API a FastAPI ASGI con arquitectura en 4 capas v3.6.0
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
"""
|
||||
Database & Persistence Management for FastAPI (Capa 4)
|
||||
Integrates SQLAlchemy Engine, SessionLocal and get_db dependency.
|
||||
"""
|
||||
from typing import Generator
|
||||
from sqlalchemy.orm import Session
|
||||
from app import create_app, db as flask_db
|
||||
|
||||
# Initialize shared application context
|
||||
flask_app = create_app()
|
||||
|
||||
def get_db() -> Generator[Session, None, None]:
|
||||
"""
|
||||
FastAPI dependency yielding the SQLAlchemy session within Flask app context
|
||||
to guarantee all models, ORM queries and services work seamlessly.
|
||||
"""
|
||||
with flask_app.app_context():
|
||||
yield flask_db.session
|
||||
|
||||
def get_flask_app():
|
||||
return flask_app
|
||||
Reference in New Issue
Block a user