Working state before icon/utils fixes - Oct 22
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
# app/core/database.py
|
||||
"""Summary description ....
|
||||
"""
|
||||
Database configuration and session management.
|
||||
|
||||
This module provides classes and functions for:
|
||||
- ....
|
||||
- ....
|
||||
- ....
|
||||
- Database engine creation and configuration
|
||||
- Session management with connection pooling
|
||||
- Database dependency for FastAPI routes
|
||||
"""
|
||||
|
||||
import logging
|
||||
@@ -21,16 +22,19 @@ Base = declarative_base()
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Database dependency with connection pooling
|
||||
|
||||
|
||||
def get_db():
|
||||
"""Get database object."""
|
||||
"""
|
||||
Database session dependency for FastAPI routes.
|
||||
|
||||
Yields a database session and ensures proper cleanup.
|
||||
Handles exceptions and rolls back transactions on error.
|
||||
"""
|
||||
db = SessionLocal()
|
||||
try:
|
||||
yield db
|
||||
except Exception as e:
|
||||
logger.error(f"Health check failed: {e}")
|
||||
logger.error(f"Database session error: {e}")
|
||||
db.rollback()
|
||||
raise
|
||||
finally:
|
||||
|
||||
Reference in New Issue
Block a user