ezKit 1.12.4__py3-none-any.whl → 1.12.6__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 +39 -18
- {ezkit-1.12.4.dist-info → ezkit-1.12.6.dist-info}/METADATA +1 -1
- {ezkit-1.12.4.dist-info → ezkit-1.12.6.dist-info}/RECORD +6 -6
- {ezkit-1.12.4.dist-info → ezkit-1.12.6.dist-info}/WHEEL +0 -0
- {ezkit-1.12.4.dist-info → ezkit-1.12.6.dist-info}/licenses/LICENSE +0 -0
- {ezkit-1.12.4.dist-info → ezkit-1.12.6.dist-info}/top_level.txt +0 -0
ezKit/database.py
CHANGED
@@ -307,6 +307,23 @@ class Database:
|
|
307
307
|
|
308
308
|
# ----------------------------------------------------------------------------------------------
|
309
309
|
|
310
|
+
def drop_table(self, table_name: str) -> bool:
|
311
|
+
"""删除表"""
|
312
|
+
|
313
|
+
info: str = f"drop table: {table_name}"
|
314
|
+
|
315
|
+
try:
|
316
|
+
logger.info(f"{info} ......")
|
317
|
+
self.connect_execute(sql=f"DROP TABLE IF EXISTS {table_name}")
|
318
|
+
logger.success(f"{info} [success]")
|
319
|
+
return True
|
320
|
+
except Exception as e:
|
321
|
+
logger.error(f"{info} [failed]")
|
322
|
+
logger.exception(e)
|
323
|
+
return False
|
324
|
+
|
325
|
+
# ----------------------------------------------------------------------------------------------
|
326
|
+
|
310
327
|
def read_with_pandas(self, method: str = "read_sql", result_type: str = "df", **kwargs) -> pd.DataFrame | list | dict:
|
311
328
|
"""读取数据"""
|
312
329
|
|
@@ -362,33 +379,37 @@ class Database:
|
|
362
379
|
|
363
380
|
# ----------------------------------------------------------------------------------------------
|
364
381
|
|
365
|
-
def
|
366
|
-
"""
|
382
|
+
def create_data(self, TS: Type, data: list) -> bool:
|
383
|
+
"""创建数据. TS: Table Schema"""
|
367
384
|
|
368
385
|
info: str = "create data"
|
369
386
|
|
370
|
-
|
387
|
+
if not utils.isTrue(data, list):
|
388
|
+
logger.error(f"{info} [data type is not a list]")
|
371
389
|
|
372
|
-
|
390
|
+
logger.info(f"{info} ......")
|
391
|
+
|
392
|
+
with Session(self.engine) as session:
|
393
|
+
|
394
|
+
try:
|
373
395
|
|
374
|
-
|
396
|
+
for item in data:
|
375
397
|
|
376
|
-
|
377
|
-
|
378
|
-
|
398
|
+
if not utils.isTrue(item, dict):
|
399
|
+
logger.error(f"{info} [data type error]")
|
400
|
+
session.rollback()
|
401
|
+
return False
|
379
402
|
|
380
|
-
|
381
|
-
logger.info(f"{info} [data type is list]")
|
382
|
-
for item in data:
|
383
|
-
session.add(TS(**item))
|
403
|
+
session.add(TS(**item))
|
384
404
|
|
385
405
|
session.commit()
|
386
406
|
|
387
|
-
|
407
|
+
logger.success(f"{info} [success]")
|
388
408
|
|
389
|
-
|
409
|
+
return True
|
390
410
|
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
411
|
+
except Exception as e:
|
412
|
+
session.rollback()
|
413
|
+
logger.error(f"{info} [failed]")
|
414
|
+
logger.exception(e)
|
415
|
+
return False
|
@@ -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=JbaBLoG0wUeu86kkroiliFB69bEZvzpt9BWRxzsy07c,14242
|
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.6.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
19
|
+
ezkit-1.12.6.dist-info/METADATA,sha256=tTGxSiL8d5cXfFIqIWd8IR8RKiXEC8Jw0r0IbLOvEC8,316
|
20
|
+
ezkit-1.12.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
21
|
+
ezkit-1.12.6.dist-info/top_level.txt,sha256=aYLB_1WODsqNTsTFWcKP-BN0KCTKcV-HZJ4zlHkCFw8,6
|
22
|
+
ezkit-1.12.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|