ezKit 1.12.42__py3-none-any.whl → 1.12.44__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 +12 -5
- {ezkit-1.12.42.dist-info → ezkit-1.12.44.dist-info}/METADATA +1 -1
- {ezkit-1.12.42.dist-info → ezkit-1.12.44.dist-info}/RECORD +6 -6
- {ezkit-1.12.42.dist-info → ezkit-1.12.44.dist-info}/WHEEL +0 -0
- {ezkit-1.12.42.dist-info → ezkit-1.12.44.dist-info}/licenses/LICENSE +0 -0
- {ezkit-1.12.42.dist-info → ezkit-1.12.44.dist-info}/top_level.txt +0 -0
ezKit/database.py
CHANGED
@@ -18,14 +18,19 @@ from loguru import logger
|
|
18
18
|
from sqlalchemy import CursorResult, Engine, Index, bindparam, create_engine, insert, text
|
19
19
|
from sqlalchemy.engine import Result
|
20
20
|
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker
|
21
|
-
from sqlalchemy.orm import DeclarativeBase, Session
|
21
|
+
from sqlalchemy.orm import DeclarativeBase, Session
|
22
22
|
|
23
23
|
from . import utils
|
24
24
|
from .errors import database_error, sqlalchemy_error
|
25
25
|
|
26
26
|
# --------------------------------------------------------------------------------------------------
|
27
27
|
|
28
|
-
|
28
|
+
|
29
|
+
class Base(DeclarativeBase):
|
30
|
+
"""所有 ORM 模型的基类"""
|
31
|
+
|
32
|
+
pass # pylint: disable=unnecessary-pass
|
33
|
+
|
29
34
|
|
30
35
|
# --------------------------------------------------------------------------------------------------
|
31
36
|
|
@@ -357,7 +362,7 @@ class Database:
|
|
357
362
|
|
358
363
|
# ----------------------------------------------------------------------------------------------
|
359
364
|
|
360
|
-
def metadata_init(self, base:
|
365
|
+
def metadata_init(self, base: type[Base], **kwargs) -> bool:
|
361
366
|
# https://stackoverflow.com/questions/19175311/how-to-create-only-one-table-with-sqlalchemy
|
362
367
|
info = "Database init table"
|
363
368
|
try:
|
@@ -785,7 +790,7 @@ async def async_create_and_count(db: DatabaseAsyncSession, schema: Type[Declarat
|
|
785
790
|
# --------------------------------------------------------------------------------------------------
|
786
791
|
|
787
792
|
|
788
|
-
async def async_read_and_count(db: DatabaseAsyncSession,
|
793
|
+
async def async_read_and_count(db: DatabaseAsyncSession, data: dict, statement_prefix: str, statement_end: str = "") -> dict:
|
789
794
|
|
790
795
|
# 初始返回结果 (适用于 count 等于 0)
|
791
796
|
result = {"count": 0, "list": [], "pageIndex": data["pageIndex"], "pageSize": 0}
|
@@ -805,7 +810,9 @@ async def async_read_and_count(db: DatabaseAsyncSession, table_name: str, data:
|
|
805
810
|
|
806
811
|
# 统计 WHERE
|
807
812
|
|
808
|
-
|
813
|
+
# table_name: str
|
814
|
+
# count_statement = text(f"SELECT COUNT(*) FROM {table_name} {where_clause}").bindparams(*bind_params)
|
815
|
+
count_statement = text(f"SELECT COUNT(*) FROM ({statement_prefix} {where_clause})").bindparams(*bind_params)
|
809
816
|
|
810
817
|
count_result = await db.operate_return_scalar_one(count_statement, statement_params)
|
811
818
|
|
@@ -4,7 +4,7 @@ ezKit/auth.py,sha256=HO19O4qOz68e0YwOP04habxMCAk42B3D7LW7yKgm9ZA,398
|
|
4
4
|
ezKit/bottle.py,sha256=43h4v1kzz6qrLvCt5IMN0H-gFtaT0koG9wETqteXsps,181666
|
5
5
|
ezKit/bottle_extensions.py,sha256=27rogmfK7mL2qUSjXH79IMGZbCVULtYEikql_N9O6Zs,1165
|
6
6
|
ezKit/cipher.py,sha256=7jBarRH7ukSYzkz-Anl8B8JzluhnRz4CLHidPRRj_cg,2939
|
7
|
-
ezKit/database.py,sha256=
|
7
|
+
ezKit/database.py,sha256=nYvh0mv1nPgJbFb3k5sheN7QS5IBTpCnqjYxINnX1As,32666
|
8
8
|
ezKit/dockerhub.py,sha256=j-wQO-71BsOgExHZhYynuy2k_hCX3on-vg0TH7QCit4,1996
|
9
9
|
ezKit/errors.py,sha256=92PggwPQfTS3Vg4og7GHYnO9CTSM7zmuh2w3kx_tSBE,1425
|
10
10
|
ezKit/fastapix.py,sha256=-nz565ASKvp3nGs9J4wORTHxlhMozqCwv8zREWpmYtI,3382
|
@@ -18,8 +18,8 @@ ezKit/token.py,sha256=Ac-i9xfq4TqpGyfCzakjrh4NYzxHiN2sCQrMk1tzVi8,1716
|
|
18
18
|
ezKit/utils.py,sha256=U457ahFkxIXuB-qWvS3995xJs-LlkFIX5_ZWVgmL5cY,43130
|
19
19
|
ezKit/xftp.py,sha256=-XQXyhMqeigT63P6sXkSS7r4GROXyqqlkzKxITLWG-g,8278
|
20
20
|
ezKit/zabbix.py,sha256=PkMnfu7mcuotwwIIsHaC9FsNg-gap6hD1xvm0AwSL1Y,33777
|
21
|
-
ezkit-1.12.
|
22
|
-
ezkit-1.12.
|
23
|
-
ezkit-1.12.
|
24
|
-
ezkit-1.12.
|
25
|
-
ezkit-1.12.
|
21
|
+
ezkit-1.12.44.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
22
|
+
ezkit-1.12.44.dist-info/METADATA,sha256=jw1B3wvM_rwcY8ae71N-MM2QY2I3XEmhKn5eStoVWwA,317
|
23
|
+
ezkit-1.12.44.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
24
|
+
ezkit-1.12.44.dist-info/top_level.txt,sha256=aYLB_1WODsqNTsTFWcKP-BN0KCTKcV-HZJ4zlHkCFw8,6
|
25
|
+
ezkit-1.12.44.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|