ezKit 1.12.20__py3-none-any.whl → 1.12.21__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 +15 -14
- {ezkit-1.12.20.dist-info → ezkit-1.12.21.dist-info}/METADATA +1 -1
- {ezkit-1.12.20.dist-info → ezkit-1.12.21.dist-info}/RECORD +6 -6
- {ezkit-1.12.20.dist-info → ezkit-1.12.21.dist-info}/WHEEL +0 -0
- {ezkit-1.12.20.dist-info → ezkit-1.12.21.dist-info}/licenses/LICENSE +0 -0
- {ezkit-1.12.20.dist-info → ezkit-1.12.21.dist-info}/top_level.txt +0 -0
ezKit/database.py
CHANGED
@@ -10,11 +10,11 @@
|
|
10
10
|
import csv
|
11
11
|
import json
|
12
12
|
from datetime import date, datetime
|
13
|
-
from typing import Any, Dict, Optional, Tuple, Type
|
13
|
+
from typing import Any, Dict, List, Optional, Tuple, Type
|
14
14
|
|
15
15
|
import pandas as pd
|
16
16
|
from loguru import logger
|
17
|
-
from sqlalchemy import CursorResult, Engine, Index, bindparam, create_engine, text
|
17
|
+
from sqlalchemy import CursorResult, Engine, Index, bindparam, create_engine, insert, text
|
18
18
|
from sqlalchemy.engine import Result
|
19
19
|
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker
|
20
20
|
from sqlalchemy.orm import DeclarativeBase, Session, declarative_base
|
@@ -607,7 +607,6 @@ class DatabaseAsyncSession:
|
|
607
607
|
|
608
608
|
async with self.AsyncSessionLocal() as session:
|
609
609
|
try:
|
610
|
-
await session.begin()
|
611
610
|
result = await session.execute(stmt, params, **kwargs)
|
612
611
|
await session.commit()
|
613
612
|
return result
|
@@ -624,7 +623,7 @@ class DatabaseAsyncSession:
|
|
624
623
|
return result.scalar_one()
|
625
624
|
|
626
625
|
# 返回所有结果
|
627
|
-
async def operate_return_mappings_all(self, stmt, params, **kwargs) ->
|
626
|
+
async def operate_return_mappings_all(self, stmt, params, **kwargs) -> List[Any]:
|
628
627
|
result = await self.operater(stmt, params, **kwargs)
|
629
628
|
if result is None:
|
630
629
|
return []
|
@@ -632,22 +631,24 @@ class DatabaseAsyncSession:
|
|
632
631
|
return [dict(row) for row in rows]
|
633
632
|
|
634
633
|
# 创建数据
|
635
|
-
async def create_with_schema(self, schema: Type, data:
|
634
|
+
async def create_with_schema(self, schema: Type[Any], data: List[dict]) -> int:
|
636
635
|
|
637
636
|
if not utils.isTrue(data, list):
|
638
|
-
return
|
637
|
+
return 0
|
639
638
|
|
640
639
|
async with self.AsyncSessionLocal() as session:
|
641
640
|
try:
|
642
|
-
for item in data:
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
641
|
+
# for item in data:
|
642
|
+
# if not utils.isTrue(item, dict):
|
643
|
+
# await session.rollback()
|
644
|
+
# return False
|
645
|
+
# # 这里不使用 await
|
646
|
+
# session.add(schema(**item))
|
647
|
+
stmt = insert(schema)
|
648
|
+
await session.execute(stmt, data)
|
648
649
|
await session.commit()
|
649
|
-
return
|
650
|
+
return len(data)
|
650
651
|
except Exception as e:
|
651
652
|
await session.rollback()
|
652
653
|
logger.exception(e)
|
653
|
-
return
|
654
|
+
return 0
|
@@ -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=EIk3fk8ygScpA858gD2piCHD9Tzu7zpu-3jYQ40CPsk,22229
|
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=U457ahFkxIXuB-qWvS3995xJs-LlkFIX5_ZWVgmL5cY,43130
|
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.21.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
19
|
+
ezkit-1.12.21.dist-info/METADATA,sha256=lhiYJh8L-EANUCp6S0v22zZNRbUlk_c4MDmguaNjEr8,317
|
20
|
+
ezkit-1.12.21.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
21
|
+
ezkit-1.12.21.dist-info/top_level.txt,sha256=aYLB_1WODsqNTsTFWcKP-BN0KCTKcV-HZJ4zlHkCFw8,6
|
22
|
+
ezkit-1.12.21.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|