ezKit 3.0.75__tar.gz → 3.0.76__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ezkit-3.0.75/ezKit.egg-info → ezkit-3.0.76}/PKG-INFO +1 -1
- {ezkit-3.0.75 → ezkit-3.0.76}/ezKit/database.py +24 -10
- {ezkit-3.0.75 → ezkit-3.0.76/ezKit.egg-info}/PKG-INFO +1 -1
- {ezkit-3.0.75 → ezkit-3.0.76}/setup.py +1 -1
- {ezkit-3.0.75 → ezkit-3.0.76}/LICENSE +0 -0
- {ezkit-3.0.75 → ezkit-3.0.76}/MANIFEST.in +0 -0
- {ezkit-3.0.75 → ezkit-3.0.76}/README.md +0 -0
- {ezkit-3.0.75 → ezkit-3.0.76}/ezKit/__init__.py +0 -0
- {ezkit-3.0.75 → ezkit-3.0.76}/ezKit/bandwagon.py +0 -0
- {ezkit-3.0.75 → ezkit-3.0.76}/ezKit/cipher.py +0 -0
- {ezkit-3.0.75 → ezkit-3.0.76}/ezKit/fastapix.py +0 -0
- {ezkit-3.0.75 → ezkit-3.0.76}/ezKit/http.py +0 -0
- {ezkit-3.0.75 → ezkit-3.0.76}/ezKit/markdown_to_html.template +0 -0
- {ezkit-3.0.75 → ezkit-3.0.76}/ezKit/markdownx.py +0 -0
- {ezkit-3.0.75 → ezkit-3.0.76}/ezKit/schema.py +0 -0
- {ezkit-3.0.75 → ezkit-3.0.76}/ezKit/sendemail.py +0 -0
- {ezkit-3.0.75 → ezkit-3.0.76}/ezKit/stock.py +0 -0
- {ezkit-3.0.75 → ezkit-3.0.76}/ezKit/utils.py +0 -0
- {ezkit-3.0.75 → ezkit-3.0.76}/ezKit.egg-info/SOURCES.txt +0 -0
- {ezkit-3.0.75 → ezkit-3.0.76}/ezKit.egg-info/dependency_links.txt +0 -0
- {ezkit-3.0.75 → ezkit-3.0.76}/ezKit.egg-info/requires.txt +0 -0
- {ezkit-3.0.75 → ezkit-3.0.76}/ezKit.egg-info/top_level.txt +0 -0
- {ezkit-3.0.75 → ezkit-3.0.76}/pyproject.toml +0 -0
- {ezkit-3.0.75 → ezkit-3.0.76}/setup.cfg +0 -0
|
@@ -515,7 +515,7 @@ class Database:
|
|
|
515
515
|
|
|
516
516
|
Returns:
|
|
517
517
|
未启用序列化时返回 `CursorResult` 或 `ScalarResult`;
|
|
518
|
-
|
|
518
|
+
启用时返回字典列表或标量列表;语句不返回行时返回空列表;执行或结果处理失败时记录错误并返回 None。
|
|
519
519
|
未序列化的结果在 Session 关闭后返回,需要注意其生命周期;
|
|
520
520
|
如需在Session 生命周期外使用结果,应启用序列化。
|
|
521
521
|
"""
|
|
@@ -534,9 +534,17 @@ class Database:
|
|
|
534
534
|
|
|
535
535
|
with self._get_db() as session:
|
|
536
536
|
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
537
|
+
raw_result: CursorResult = session.execute(stmt, execution_params, **kwargs)
|
|
538
|
+
|
|
539
|
+
# 序列化前检查 returns_rows
|
|
540
|
+
# INSERT、DELETE 等无返回行的语句,
|
|
541
|
+
# 执行成功时,返回 [],不会再调用 .mappings().all() 或 .all(),避免触发 ResourceClosedError。
|
|
542
|
+
# 执行失败时,会触发 Exception,返回 None。
|
|
543
|
+
if serialize and not raw_result.returns_rows:
|
|
544
|
+
logger.success(f"{info} | success")
|
|
545
|
+
return []
|
|
546
|
+
|
|
547
|
+
result: CursorResult | ScalarResult = raw_result.scalars() if scalars else raw_result
|
|
540
548
|
|
|
541
549
|
if serialize and isinstance(result, CursorResult):
|
|
542
550
|
rows = result.mappings().all()
|
|
@@ -1058,7 +1066,7 @@ class AsyncDatabase:
|
|
|
1058
1066
|
|
|
1059
1067
|
Returns:
|
|
1060
1068
|
未启用序列化时返回 `CursorResult` 或 `ScalarResult`;
|
|
1061
|
-
|
|
1069
|
+
启用时返回字典列表或标量列表;语句不返回行时返回空列表;执行或结果处理失败时记录错误并返回 None。
|
|
1062
1070
|
未序列化的结果在 Session 关闭后返回,需要注意其生命周期;
|
|
1063
1071
|
如需在Session 生命周期外使用结果,应启用序列化。
|
|
1064
1072
|
"""
|
|
@@ -1078,11 +1086,17 @@ class AsyncDatabase:
|
|
|
1078
1086
|
async with self._get_db() as session:
|
|
1079
1087
|
|
|
1080
1088
|
# AsyncSession.execute() 的类型标注较宽,运行时结果仍按 CursorResult 处理。
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
)
|
|
1089
|
+
raw_result: CursorResult = await session.execute(stmt, execution_params, **kwargs) # type: ignore
|
|
1090
|
+
|
|
1091
|
+
# 序列化前检查 returns_rows
|
|
1092
|
+
# INSERT、DELETE 等无返回行的语句,
|
|
1093
|
+
# 执行成功时,返回 [],不会再调用 .mappings().all() 或 .all(),避免触发 ResourceClosedError。
|
|
1094
|
+
# 执行失败时,会触发 Exception,返回 None。
|
|
1095
|
+
if serialize and not raw_result.returns_rows:
|
|
1096
|
+
logger.success(f"{info} | success")
|
|
1097
|
+
return []
|
|
1098
|
+
|
|
1099
|
+
result: CursorResult | ScalarResult = raw_result.scalars() if scalars else raw_result
|
|
1086
1100
|
|
|
1087
1101
|
if serialize and isinstance(result, CursorResult):
|
|
1088
1102
|
rows = result.mappings().all()
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|