aiteamutils 0.2.1__tar.gz → 0.2.3__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {aiteamutils-0.2.1 → aiteamutils-0.2.3}/PKG-INFO +12 -6
- {aiteamutils-0.2.1 → aiteamutils-0.2.3}/README.md +11 -5
- {aiteamutils-0.2.1 → aiteamutils-0.2.3}/aiteamutils/__init__.py +3 -4
- {aiteamutils-0.2.1 → aiteamutils-0.2.3}/aiteamutils/base_repository.py +3 -3
- {aiteamutils-0.2.1 → aiteamutils-0.2.3}/aiteamutils/base_service.py +1 -1
- {aiteamutils-0.2.1 → aiteamutils-0.2.3}/aiteamutils/validators.py +1 -1
- aiteamutils-0.2.3/aiteamutils/version.py +2 -0
- {aiteamutils-0.2.1 → aiteamutils-0.2.3}/pyproject.toml +4 -1
- {aiteamutils-0.2.1 → aiteamutils-0.2.3}/.gitignore +0 -0
- {aiteamutils-0.2.1 → aiteamutils-0.2.3}/aiteamutils/base_model.py +0 -0
- {aiteamutils-0.2.1 → aiteamutils-0.2.3}/aiteamutils/cache.py +0 -0
- {aiteamutils-0.2.1 → aiteamutils-0.2.3}/aiteamutils/config.py +0 -0
- {aiteamutils-0.2.1 → aiteamutils-0.2.3}/aiteamutils/database.py +0 -0
- {aiteamutils-0.2.1 → aiteamutils-0.2.3}/aiteamutils/dependencies.py +0 -0
- {aiteamutils-0.2.1 → aiteamutils-0.2.3}/aiteamutils/enums.py +0 -0
- {aiteamutils-0.2.1 → aiteamutils-0.2.3}/aiteamutils/exceptions.py +0 -0
- {aiteamutils-0.2.1 → aiteamutils-0.2.3}/aiteamutils/security.py +0 -0
- {aiteamutils-0.2.1 → aiteamutils-0.2.3}/setup.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: aiteamutils
|
3
|
-
Version: 0.2.
|
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
|
31
|
-
from aiteamutils.base_model import Base
|
30
|
+
from aiteamutils.database import DatabaseService
|
32
31
|
|
33
|
-
# DB
|
34
|
-
|
32
|
+
# DB 서비스 초기화
|
33
|
+
db_service = DatabaseService("postgresql+asyncpg://user:pass@localhost/db")
|
35
34
|
|
36
35
|
# DB 세션 사용
|
37
|
-
async with
|
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 토큰 관리
|
@@ -11,17 +11,21 @@ pip install aiteamutils
|
|
11
11
|
## 사용 예시
|
12
12
|
|
13
13
|
```python
|
14
|
-
from aiteamutils.database import
|
15
|
-
from aiteamutils.base_model import Base
|
14
|
+
from aiteamutils.database import DatabaseService
|
16
15
|
|
17
|
-
# DB
|
18
|
-
|
16
|
+
# DB 서비스 초기화
|
17
|
+
db_service = DatabaseService("postgresql+asyncpg://user:pass@localhost/db")
|
19
18
|
|
20
19
|
# DB 세션 사용
|
21
|
-
async with
|
20
|
+
async with db_service.get_db() as session:
|
22
21
|
# DB 작업 수행
|
23
22
|
pass
|
24
23
|
|
24
|
+
# 트랜잭션 사용
|
25
|
+
async with db_service.transaction():
|
26
|
+
# 트랜잭션 내 작업 수행
|
27
|
+
result = await db_service.create_entity(UserModel, {"name": "test"})
|
28
|
+
|
25
29
|
# 예외 처리
|
26
30
|
from aiteamutils.exceptions import CustomException, ErrorCode
|
27
31
|
|
@@ -39,6 +43,8 @@ except CustomException as e:
|
|
39
43
|
- 세션 관리
|
40
44
|
- 트랜잭션 관리
|
41
45
|
- 기본 CRUD 작업
|
46
|
+
- 외래키 검증
|
47
|
+
- 유니크 필드 검증
|
42
48
|
|
43
49
|
- 인증/인가 유틸리티
|
44
50
|
- JWT 토큰 관리
|
@@ -1,5 +1,5 @@
|
|
1
1
|
from .base_model import Base
|
2
|
-
from .database import
|
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
|
-
"
|
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
|
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:
|
17
|
+
def __init__(self, db_service: DatabaseManager, model: Type[ModelType]):
|
18
18
|
"""
|
19
19
|
Args:
|
20
|
-
db_service (
|
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
|
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
|
@@ -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
|
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):
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "aiteamutils"
|
7
|
-
|
7
|
+
dynamic = ["version"]
|
8
8
|
authors = [
|
9
9
|
{ name="AI Team" },
|
10
10
|
]
|
@@ -27,5 +27,8 @@ dependencies = [
|
|
27
27
|
Homepage = "https://github.com/yourusername/aiteamutils"
|
28
28
|
Issues = "https://github.com/yourusername/aiteamutils/issues"
|
29
29
|
|
30
|
+
[tool.hatch.version]
|
31
|
+
path = "aiteamutils/version.py"
|
32
|
+
|
30
33
|
[tool.hatch.build.targets.wheel]
|
31
34
|
packages = ["aiteamutils"]
|
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
|