aiteamutils 0.2.41__py3-none-any.whl → 0.2.42__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
aiteamutils/database.py CHANGED
@@ -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
- return DatabaseService(session=db)
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__(
aiteamutils/version.py CHANGED
@@ -1,2 +1,2 @@
1
1
  """버전 정보"""
2
- __version__ = "0.2.41"
2
+ __version__ = "0.2.42"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aiteamutils
3
- Version: 0.2.41
3
+ Version: 0.2.42
4
4
  Summary: AI Team Utilities
5
5
  Project-URL: Homepage, https://github.com/yourusername/aiteamutils
6
6
  Project-URL: Issues, https://github.com/yourusername/aiteamutils/issues
@@ -4,13 +4,13 @@ aiteamutils/base_repository.py,sha256=qdwQ7Sj2fUqxpDg6cWM48n_QbwPK_VUlG9zTSem8iC
4
4
  aiteamutils/base_service.py,sha256=E4dHGE0DvhmRyFplh46SwKJOSF_nUL7OAsCkf_ZJF_8,24733
5
5
  aiteamutils/cache.py,sha256=tr0Yn8VPYA9QHiKCUzciVlQ2J1RAwNo2K9lGMH4rY3s,1334
6
6
  aiteamutils/config.py,sha256=kFKMeIx1KcuEwwx4VjZdCgoTOHCkG3ySYVJ0G6cvMoA,2849
7
- aiteamutils/database.py,sha256=l_ZykepKquKRdsBZwLAeLHEYxhM4Ac4bknWtYNHurOo,35928
7
+ aiteamutils/database.py,sha256=oI36mW94Hnn5laS3YcsAyuofFsQzbj3TXT-HRb3SYk8,37029
8
8
  aiteamutils/dependencies.py,sha256=hsJ-kc8ic4U6vKFtUIWjhBE1_Bm-sya5UqSb2zMH5oM,5731
9
9
  aiteamutils/enums.py,sha256=ipZi6k_QD5-3QV7Yzv7bnL0MjDz-vqfO9I5L77biMKs,632
10
10
  aiteamutils/exceptions.py,sha256=_lKWXq_ujNj41xN6LDE149PwsecAP7lgYWbOBbLOntg,15368
11
11
  aiteamutils/security.py,sha256=9gvEqDtE3RJaoCWqELPCjkg-IsSqZVrpMP6XPZaodWU,16024
12
12
  aiteamutils/validators.py,sha256=3N245cZFjgwtW_KzjESkizx5BBUDaJLbbxfNO4WOFZ0,7764
13
- aiteamutils/version.py,sha256=DT95upAYup68_YP0gm-cFpVbBYlrV8Snq10ztLShyy4,42
14
- aiteamutils-0.2.41.dist-info/METADATA,sha256=LiQlMTbzxNqm_cZSqVunU5siBxpF-G0jhI5UqP3RC7c,1718
15
- aiteamutils-0.2.41.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
- aiteamutils-0.2.41.dist-info/RECORD,,
13
+ aiteamutils/version.py,sha256=smfyzeeMHy2PIy96IdATpp51v_Y3aEPYazLKs09uNSM,42
14
+ aiteamutils-0.2.42.dist-info/METADATA,sha256=Bn-kxta6CUfeOYPzE03yrlm-4k5p5NqKOzln7YB9E7U,1718
15
+ aiteamutils-0.2.42.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
+ aiteamutils-0.2.42.dist-info/RECORD,,