aiteamutils 0.2.41__tar.gz → 0.2.42__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {aiteamutils-0.2.41 → aiteamutils-0.2.42}/PKG-INFO +1 -1
- {aiteamutils-0.2.41 → aiteamutils-0.2.42}/aiteamutils/database.py +33 -2
- aiteamutils-0.2.42/aiteamutils/version.py +2 -0
- aiteamutils-0.2.41/aiteamutils/version.py +0 -2
- {aiteamutils-0.2.41 → aiteamutils-0.2.42}/.cursorrules +0 -0
- {aiteamutils-0.2.41 → aiteamutils-0.2.42}/.gitignore +0 -0
- {aiteamutils-0.2.41 → aiteamutils-0.2.42}/README.md +0 -0
- {aiteamutils-0.2.41 → aiteamutils-0.2.42}/aiteamutils/__init__.py +0 -0
- {aiteamutils-0.2.41 → aiteamutils-0.2.42}/aiteamutils/base_model.py +0 -0
- {aiteamutils-0.2.41 → aiteamutils-0.2.42}/aiteamutils/base_repository.py +0 -0
- {aiteamutils-0.2.41 → aiteamutils-0.2.42}/aiteamutils/base_service.py +0 -0
- {aiteamutils-0.2.41 → aiteamutils-0.2.42}/aiteamutils/cache.py +0 -0
- {aiteamutils-0.2.41 → aiteamutils-0.2.42}/aiteamutils/config.py +0 -0
- {aiteamutils-0.2.41 → aiteamutils-0.2.42}/aiteamutils/dependencies.py +0 -0
- {aiteamutils-0.2.41 → aiteamutils-0.2.42}/aiteamutils/enums.py +0 -0
- {aiteamutils-0.2.41 → aiteamutils-0.2.42}/aiteamutils/exceptions.py +0 -0
- {aiteamutils-0.2.41 → aiteamutils-0.2.42}/aiteamutils/security.py +0 -0
- {aiteamutils-0.2.41 → aiteamutils-0.2.42}/aiteamutils/validators.py +0 -0
- {aiteamutils-0.2.41 → aiteamutils-0.2.42}/pyproject.toml +0 -0
- {aiteamutils-0.2.41 → aiteamutils-0.2.42}/setup.py +0 -0
@@ -47,8 +47,21 @@ async def get_db() -> AsyncGenerator[AsyncSession, None]:
|
|
47
47
|
CustomException: 세션 생성 실패 시
|
48
48
|
"""
|
49
49
|
db_service = get_database_service()
|
50
|
+
if not db_service or not db_service.engine:
|
51
|
+
raise CustomException(
|
52
|
+
ErrorCode.DB_CONNECTION_ERROR,
|
53
|
+
detail="Database service or engine is not properly initialized",
|
54
|
+
source_function="get_db"
|
55
|
+
)
|
56
|
+
|
50
57
|
try:
|
51
58
|
async with db_service.get_session() as session:
|
59
|
+
if session is None:
|
60
|
+
raise CustomException(
|
61
|
+
ErrorCode.DB_CONNECTION_ERROR,
|
62
|
+
detail="Failed to create database session",
|
63
|
+
source_function="get_db"
|
64
|
+
)
|
52
65
|
yield session
|
53
66
|
except Exception as e:
|
54
67
|
raise CustomException(
|
@@ -58,7 +71,7 @@ async def get_db() -> AsyncGenerator[AsyncSession, None]:
|
|
58
71
|
original_error=e
|
59
72
|
)
|
60
73
|
finally:
|
61
|
-
if 'session' in locals():
|
74
|
+
if 'session' in locals() and session is not None:
|
62
75
|
await session.close()
|
63
76
|
|
64
77
|
def get_database_session(db: AsyncSession = Depends(get_db)) -> 'DatabaseService':
|
@@ -69,8 +82,26 @@ def get_database_session(db: AsyncSession = Depends(get_db)) -> 'DatabaseService
|
|
69
82
|
|
70
83
|
Returns:
|
71
84
|
DatabaseService: DatabaseService 인스턴스
|
85
|
+
|
86
|
+
Raises:
|
87
|
+
CustomException: 데이터베이스 세션이 유효하지 않은 경우
|
72
88
|
"""
|
73
|
-
|
89
|
+
if db is None:
|
90
|
+
raise CustomException(
|
91
|
+
ErrorCode.DB_CONNECTION_ERROR,
|
92
|
+
detail="Database session is not initialized",
|
93
|
+
source_function="get_database_session"
|
94
|
+
)
|
95
|
+
|
96
|
+
db_service = DatabaseService(session=db)
|
97
|
+
if db_service.db is None:
|
98
|
+
raise CustomException(
|
99
|
+
ErrorCode.DB_CONNECTION_ERROR,
|
100
|
+
detail="Failed to initialize database session",
|
101
|
+
source_function="get_database_session"
|
102
|
+
)
|
103
|
+
|
104
|
+
return db_service
|
74
105
|
|
75
106
|
class DatabaseService:
|
76
107
|
def __init__(
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|