ezKit 1.12.9__py3-none-any.whl → 1.12.10__py3-none-any.whl
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/database.py +42 -0
- {ezkit-1.12.9.dist-info → ezkit-1.12.10.dist-info}/METADATA +1 -1
- {ezkit-1.12.9.dist-info → ezkit-1.12.10.dist-info}/RECORD +6 -6
- {ezkit-1.12.9.dist-info → ezkit-1.12.10.dist-info}/WHEEL +0 -0
- {ezkit-1.12.9.dist-info → ezkit-1.12.10.dist-info}/licenses/LICENSE +0 -0
- {ezkit-1.12.9.dist-info → ezkit-1.12.10.dist-info}/top_level.txt +0 -0
ezKit/database.py
CHANGED
@@ -22,6 +22,45 @@ from . import utils
|
|
22
22
|
Base = declarative_base()
|
23
23
|
|
24
24
|
|
25
|
+
# --------------------------------------------------------------------------------------------------
|
26
|
+
|
27
|
+
|
28
|
+
def get_limit_offset(page_index: int, page_size: int) -> tuple[int, int] | None:
|
29
|
+
"""
|
30
|
+
根据 page_index (页码) 和 page_size (每页数量) 计算 SQL 的 LIMIT 和 OFFSET
|
31
|
+
|
32
|
+
参数:
|
33
|
+
|
34
|
+
page_index (int): 当前页码, 从 1 开始
|
35
|
+
page_size (int): 每页数量, 必须 > 0
|
36
|
+
|
37
|
+
返回:
|
38
|
+
(limit, offset): limit 表示取多少条,offset 表示跳过多少条
|
39
|
+
"""
|
40
|
+
try:
|
41
|
+
|
42
|
+
# 默认第 1 页
|
43
|
+
# if page_index < 1:
|
44
|
+
# page_index = 1
|
45
|
+
page_index = max(page_index, 1)
|
46
|
+
|
47
|
+
# 默认每页 10 条
|
48
|
+
if page_size < 1:
|
49
|
+
page_size = 10
|
50
|
+
|
51
|
+
offset = (page_index - 1) * page_size
|
52
|
+
|
53
|
+
# LIMIT, OFFSET
|
54
|
+
return page_size, offset
|
55
|
+
|
56
|
+
except Exception as e:
|
57
|
+
logger.exception(e)
|
58
|
+
return None
|
59
|
+
|
60
|
+
|
61
|
+
# --------------------------------------------------------------------------------------------------
|
62
|
+
|
63
|
+
|
25
64
|
def orm_object_to_dict(obj, include: list | None = None) -> dict | None:
|
26
65
|
"""
|
27
66
|
将 ORM 对象转为 dict, 可选择只包含部分字段.
|
@@ -67,6 +106,9 @@ def orm_to_dict(obj, include: list | None = None) -> dict | list | None:
|
|
67
106
|
return None
|
68
107
|
|
69
108
|
|
109
|
+
# --------------------------------------------------------------------------------------------------
|
110
|
+
|
111
|
+
|
70
112
|
def build_raw_where_clause(data: dict) -> tuple[str, list] | None:
|
71
113
|
"""
|
72
114
|
将字段数据转换为 SQL WHERE 条件(使用原生 SQL)
|
@@ -3,7 +3,7 @@ ezKit/_file.py,sha256=0qRZhwYuagTgTGrhm-tzAMvEQT4HTJA_xZKqF2bo0ho,1207
|
|
3
3
|
ezKit/bottle.py,sha256=43h4v1kzz6qrLvCt5IMN0H-gFtaT0koG9wETqteXsps,181666
|
4
4
|
ezKit/bottle_extensions.py,sha256=27rogmfK7mL2qUSjXH79IMGZbCVULtYEikql_N9O6Zs,1165
|
5
5
|
ezKit/cipher.py,sha256=7jBarRH7ukSYzkz-Anl8B8JzluhnRz4CLHidPRRj_cg,2939
|
6
|
-
ezKit/database.py,sha256=
|
6
|
+
ezKit/database.py,sha256=L1PoVSXGou3NcndckChdaJ09y1KiXrdlv_EWrv02rwI,18588
|
7
7
|
ezKit/dockerhub.py,sha256=j-wQO-71BsOgExHZhYynuy2k_hCX3on-vg0TH7QCit4,1996
|
8
8
|
ezKit/http.py,sha256=zhNxJF-x91UqGncXWxVXnhZVpFo_wmmpGnMXVT11y9E,1832
|
9
9
|
ezKit/markdown_to_html.template,sha256=21G2sSVGJn6aJvHd0NN4zY5YiDteKe4UtW36AzBwSdk,22274
|
@@ -15,8 +15,8 @@ ezKit/token.py,sha256=Ac-i9xfq4TqpGyfCzakjrh4NYzxHiN2sCQrMk1tzVi8,1716
|
|
15
15
|
ezKit/utils.py,sha256=VyAw2yEs15VER9RCpMgskx1l0zrSpRlV34X___eOia0,42416
|
16
16
|
ezKit/xftp.py,sha256=-XQXyhMqeigT63P6sXkSS7r4GROXyqqlkzKxITLWG-g,8278
|
17
17
|
ezKit/zabbix.py,sha256=PkMnfu7mcuotwwIIsHaC9FsNg-gap6hD1xvm0AwSL1Y,33777
|
18
|
-
ezkit-1.12.
|
19
|
-
ezkit-1.12.
|
20
|
-
ezkit-1.12.
|
21
|
-
ezkit-1.12.
|
22
|
-
ezkit-1.12.
|
18
|
+
ezkit-1.12.10.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
19
|
+
ezkit-1.12.10.dist-info/METADATA,sha256=ZcBYnwPSUU70uuJgaxwIFT7Kf2VEqD-DMUP99O1rQHE,317
|
20
|
+
ezkit-1.12.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
21
|
+
ezkit-1.12.10.dist-info/top_level.txt,sha256=aYLB_1WODsqNTsTFWcKP-BN0KCTKcV-HZJ4zlHkCFw8,6
|
22
|
+
ezkit-1.12.10.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|