aiteamutils 0.2.1__py3-none-any.whl → 0.2.3__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
aiteamutils/__init__.py CHANGED
@@ -1,5 +1,5 @@
1
1
  from .base_model import Base
2
- from .database import DatabaseManager
2
+ from .database import DatabaseService
3
3
  from .exceptions import (
4
4
  CustomException,
5
5
  ErrorCode,
@@ -21,8 +21,7 @@ from .base_repository import BaseRepository
21
21
  from .validators import validate_with
22
22
  from .enums import ActivityType
23
23
  from .cache import CacheManager
24
-
25
- __version__ = "0.1.0"
24
+ from .version import __version__
26
25
 
27
26
  __all__ = [
28
27
  # Base Models
@@ -31,7 +30,7 @@ __all__ = [
31
30
  "BaseRepository",
32
31
 
33
32
  # Database
34
- "DatabaseManager",
33
+ "DatabaseService",
35
34
 
36
35
  # Exceptions
37
36
  "CustomException",
@@ -3,7 +3,7 @@ from typing import TypeVar, Generic, Dict, Any, List, Optional, Type
3
3
  from sqlalchemy.orm import DeclarativeBase
4
4
  from sqlalchemy.exc import IntegrityError, SQLAlchemyError
5
5
  from sqlalchemy import select, or_, and_
6
- from .database import DatabaseService
6
+ from .database import DatabaseManager
7
7
  from .exceptions import CustomException, ErrorCode
8
8
  from sqlalchemy.orm import joinedload
9
9
  from sqlalchemy.sql import Select
@@ -14,10 +14,10 @@ class BaseRepository(Generic[ModelType]):
14
14
  ##################
15
15
  # 1. 초기화 영역 #
16
16
  ##################
17
- def __init__(self, db_service: DatabaseService, model: Type[ModelType]):
17
+ def __init__(self, db_service: DatabaseManager, model: Type[ModelType]):
18
18
  """
19
19
  Args:
20
- db_service (DatabaseService): 데이터베이스 서비스 인스턴스
20
+ db_service (DatabaseManager): 데이터베이스 서비스 인스턴스
21
21
  model (Type[ModelType]): 모델 클래스
22
22
  """
23
23
  self.db_service = db_service
@@ -3,7 +3,7 @@ from datetime import datetime
3
3
  from typing import TypeVar, Generic, Dict, Any, List, Optional, Type, Union
4
4
  from sqlalchemy.orm import DeclarativeBase
5
5
  from sqlalchemy.exc import IntegrityError, SQLAlchemyError
6
- from .database import DatabaseService
6
+ from .database import DatabaseManager
7
7
  from .exceptions import CustomException, ErrorCode
8
8
  from .base_repository import BaseRepository
9
9
  from .security import hash_password
aiteamutils/validators.py CHANGED
@@ -7,7 +7,7 @@ from pydantic import field_validator
7
7
  import re
8
8
 
9
9
  from .exceptions import ErrorCode, CustomException
10
- from .database import DatabaseService
10
+ from .database import DatabaseManager
11
11
  from .base_model import Base
12
12
 
13
13
  def validate_with(validator_func, unique_check=None, skip_if_none=False):
aiteamutils/version.py ADDED
@@ -0,0 +1,2 @@
1
+ """버전 정보"""
2
+ __version__ = "0.2.3"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aiteamutils
3
- Version: 0.2.1
3
+ Version: 0.2.3
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
@@ -27,17 +27,21 @@ pip install aiteamutils
27
27
  ## 사용 예시
28
28
 
29
29
  ```python
30
- from aiteamutils.database import DatabaseManager
31
- from aiteamutils.base_model import Base
30
+ from aiteamutils.database import DatabaseService
32
31
 
33
- # DB 매니저 초기화
34
- db = DatabaseManager("postgresql+asyncpg://user:pass@localhost/db")
32
+ # DB 서비스 초기화
33
+ db_service = DatabaseService("postgresql+asyncpg://user:pass@localhost/db")
35
34
 
36
35
  # DB 세션 사용
37
- async with db.get_session() as session:
36
+ async with db_service.get_db() as session:
38
37
  # DB 작업 수행
39
38
  pass
40
39
 
40
+ # 트랜잭션 사용
41
+ async with db_service.transaction():
42
+ # 트랜잭션 내 작업 수행
43
+ result = await db_service.create_entity(UserModel, {"name": "test"})
44
+
41
45
  # 예외 처리
42
46
  from aiteamutils.exceptions import CustomException, ErrorCode
43
47
 
@@ -55,6 +59,8 @@ except CustomException as e:
55
59
  - 세션 관리
56
60
  - 트랜잭션 관리
57
61
  - 기본 CRUD 작업
62
+ - 외래키 검증
63
+ - 유니크 필드 검증
58
64
 
59
65
  - 인증/인가 유틸리티
60
66
  - JWT 토큰 관리
@@ -1,7 +1,7 @@
1
- aiteamutils/__init__.py,sha256=zmfBXBwNWdbJKCt1rmHk_czHJLmVF-oqRuqq8tf0t0U,1229
1
+ aiteamutils/__init__.py,sha256=-pgR1RkjBjcIgfkKSeEy65G6jsDStFM4DdiQU8Fwcmg,1239
2
2
  aiteamutils/base_model.py,sha256=ODEnjvUVoxQ1RPCfq8-uZTfTADIA4c7Z3E6G4EVsSX0,2708
3
- aiteamutils/base_repository.py,sha256=0772JYHpF82vZzR8l21rDcZk8uVj6r52rqJdp150qiE,18927
4
- aiteamutils/base_service.py,sha256=nW9sC0SHDIve3WJVUB3rAS_9XGTkIYJRaDxfqA0V3js,24727
3
+ aiteamutils/base_repository.py,sha256=TQAXajQaaXIAJAFr9n5R2ikcu1TSq-E-_AjXgsND5c4,18927
4
+ aiteamutils/base_service.py,sha256=cqPP74ya6r8twJyU3Bc6ARxKiRL8fQIIZZnhDHxBQXE,24727
5
5
  aiteamutils/cache.py,sha256=tr0Yn8VPYA9QHiKCUzciVlQ2J1RAwNo2K9lGMH4rY3s,1334
6
6
  aiteamutils/config.py,sha256=vC6k6E2-Y4mD0E0kw6WVgSatCl9K_BtTwrVFhLrhCzs,665
7
7
  aiteamutils/database.py,sha256=U71cexPsSmMTKgp098I574PupqnuPltujI4QKHBG2Cc,29952
@@ -9,7 +9,8 @@ aiteamutils/dependencies.py,sha256=EJeVtq_lACuoheVhkX23N9xiak9bGD-t3-2JtlgBki0,4
9
9
  aiteamutils/enums.py,sha256=ipZi6k_QD5-3QV7Yzv7bnL0MjDz-vqfO9I5L77biMKs,632
10
10
  aiteamutils/exceptions.py,sha256=YV-ISya4wQlHk4twvGo16I5r8h22-tXpn9wa-b3WwDM,15231
11
11
  aiteamutils/security.py,sha256=AZszaTxVEGi1jU1sX3QXHGgshp1lVvd0xXvZejXvs_w,12643
12
- aiteamutils/validators.py,sha256=BQA61f5raVAX0BGcTIS3Ht6CyCAdHgqDUmr76bZWgYE,7630
13
- aiteamutils-0.2.1.dist-info/METADATA,sha256=po2f8eh0FjaU3112Gr7ANaovAU8SZbLaBEfTShZqhXU,1527
14
- aiteamutils-0.2.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
15
- aiteamutils-0.2.1.dist-info/RECORD,,
12
+ aiteamutils/validators.py,sha256=GA2idwDtbQynle7tya10cAnJ6DvLIFsJ746We0V-30k,7630
13
+ aiteamutils/version.py,sha256=DXa_l8uxY6IUVYMN7t-_ZT77POxKLF32FEOkXcMp20g,42
14
+ aiteamutils-0.2.3.dist-info/METADATA,sha256=I4CrdombApVWW8HLn3C6hA6lMTDUETpdEOV14iGmOko,1717
15
+ aiteamutils-0.2.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
+ aiteamutils-0.2.3.dist-info/RECORD,,