aiteamutils 0.2.49__tar.gz → 0.2.51__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {aiteamutils-0.2.49 → aiteamutils-0.2.51}/PKG-INFO +1 -1
- {aiteamutils-0.2.49 → aiteamutils-0.2.51}/aiteamutils/database.py +11 -43
- aiteamutils-0.2.51/aiteamutils/version.py +2 -0
- aiteamutils-0.2.49/aiteamutils/version.py +0 -2
- {aiteamutils-0.2.49 → aiteamutils-0.2.51}/.cursorrules +0 -0
- {aiteamutils-0.2.49 → aiteamutils-0.2.51}/.gitignore +0 -0
- {aiteamutils-0.2.49 → aiteamutils-0.2.51}/README.md +0 -0
- {aiteamutils-0.2.49 → aiteamutils-0.2.51}/aiteamutils/__init__.py +0 -0
- {aiteamutils-0.2.49 → aiteamutils-0.2.51}/aiteamutils/base_model.py +0 -0
- {aiteamutils-0.2.49 → aiteamutils-0.2.51}/aiteamutils/base_repository.py +0 -0
- {aiteamutils-0.2.49 → aiteamutils-0.2.51}/aiteamutils/base_service.py +0 -0
- {aiteamutils-0.2.49 → aiteamutils-0.2.51}/aiteamutils/cache.py +0 -0
- {aiteamutils-0.2.49 → aiteamutils-0.2.51}/aiteamutils/config.py +0 -0
- {aiteamutils-0.2.49 → aiteamutils-0.2.51}/aiteamutils/dependencies.py +0 -0
- {aiteamutils-0.2.49 → aiteamutils-0.2.51}/aiteamutils/enums.py +0 -0
- {aiteamutils-0.2.49 → aiteamutils-0.2.51}/aiteamutils/exceptions.py +0 -0
- {aiteamutils-0.2.49 → aiteamutils-0.2.51}/aiteamutils/security.py +0 -0
- {aiteamutils-0.2.49 → aiteamutils-0.2.51}/aiteamutils/validators.py +0 -0
- {aiteamutils-0.2.49 → aiteamutils-0.2.51}/pyproject.toml +0 -0
- {aiteamutils-0.2.49 → aiteamutils-0.2.51}/setup.py +0 -0
@@ -997,62 +997,30 @@ class DatabaseService:
|
|
997
997
|
)
|
998
998
|
|
999
999
|
async def get_db() -> AsyncGenerator[AsyncSession, None]:
|
1000
|
-
"""데이터베이스
|
1001
|
-
|
1000
|
+
"""데이터베이스 세션 의존성
|
1001
|
+
|
1002
1002
|
Yields:
|
1003
1003
|
AsyncSession: 데이터베이스 세션
|
1004
|
-
|
1004
|
+
|
1005
1005
|
Raises:
|
1006
|
-
CustomException:
|
1006
|
+
CustomException: 데이터베이스 연결 오류
|
1007
1007
|
"""
|
1008
|
-
|
1009
|
-
raise CustomException(
|
1010
|
-
ErrorCode.DB_CONNECTION_ERROR,
|
1011
|
-
detail="Database service is not initialized",
|
1012
|
-
source_function="get_db"
|
1013
|
-
)
|
1014
|
-
|
1015
|
-
db_service = await DatabaseServiceManager.get_instance()
|
1016
|
-
if not db_service or not db_service.engine:
|
1017
|
-
raise CustomException(
|
1018
|
-
ErrorCode.DB_CONNECTION_ERROR,
|
1019
|
-
detail="Database service or engine is not properly initialized",
|
1020
|
-
source_function="get_db"
|
1021
|
-
)
|
1008
|
+
db_service = await get_database_service()
|
1022
1009
|
|
1023
|
-
|
1024
|
-
session = db_service.get_session()
|
1025
|
-
if session is None:
|
1026
|
-
raise CustomException(
|
1027
|
-
ErrorCode.DB_CONNECTION_ERROR,
|
1028
|
-
detail="Failed to create database session",
|
1029
|
-
source_function="get_db"
|
1030
|
-
)
|
1031
|
-
|
1032
|
-
# 세션이 유효한지 확인
|
1010
|
+
async with db_service.get_session() as session:
|
1033
1011
|
try:
|
1012
|
+
# 세션이 유효한지 확인
|
1034
1013
|
await session.execute(select(1))
|
1014
|
+
yield session
|
1035
1015
|
except Exception as e:
|
1036
|
-
|
1016
|
+
if isinstance(e, CustomException):
|
1017
|
+
raise e
|
1037
1018
|
raise CustomException(
|
1038
1019
|
ErrorCode.DB_CONNECTION_ERROR,
|
1039
|
-
detail="
|
1020
|
+
detail=f"Failed to get database session: {str(e)}",
|
1040
1021
|
source_function="get_db",
|
1041
1022
|
original_error=e
|
1042
1023
|
)
|
1043
|
-
|
1044
|
-
yield session
|
1045
|
-
except Exception as e:
|
1046
|
-
if isinstance(e, CustomException):
|
1047
|
-
raise e
|
1048
|
-
raise CustomException(
|
1049
|
-
ErrorCode.DB_CONNECTION_ERROR,
|
1050
|
-
detail=f"Failed to get database session: {str(e)}",
|
1051
|
-
source_function="get_db",
|
1052
|
-
original_error=e
|
1053
|
-
)
|
1054
|
-
finally:
|
1055
|
-
await session.close()
|
1056
1024
|
|
1057
1025
|
async def get_database_service() -> DatabaseService:
|
1058
1026
|
"""DatabaseService 의존성
|
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
|