ezKit 1.12.2__tar.gz → 1.12.3__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.
Files changed (28) hide show
  1. {ezkit-1.12.2/ezKit.egg-info → ezkit-1.12.3}/PKG-INFO +1 -1
  2. {ezkit-1.12.2 → ezkit-1.12.3}/ezKit/database.py +35 -2
  3. {ezkit-1.12.2 → ezkit-1.12.3/ezKit.egg-info}/PKG-INFO +1 -1
  4. {ezkit-1.12.2 → ezkit-1.12.3}/setup.py +1 -1
  5. {ezkit-1.12.2 → ezkit-1.12.3}/LICENSE +0 -0
  6. {ezkit-1.12.2 → ezkit-1.12.3}/MANIFEST.in +0 -0
  7. {ezkit-1.12.2 → ezkit-1.12.3}/README.md +0 -0
  8. {ezkit-1.12.2 → ezkit-1.12.3}/ezKit/__init__.py +0 -0
  9. {ezkit-1.12.2 → ezkit-1.12.3}/ezKit/_file.py +0 -0
  10. {ezkit-1.12.2 → ezkit-1.12.3}/ezKit/bottle.py +0 -0
  11. {ezkit-1.12.2 → ezkit-1.12.3}/ezKit/bottle_extensions.py +0 -0
  12. {ezkit-1.12.2 → ezkit-1.12.3}/ezKit/cipher.py +0 -0
  13. {ezkit-1.12.2 → ezkit-1.12.3}/ezKit/dockerhub.py +0 -0
  14. {ezkit-1.12.2 → ezkit-1.12.3}/ezKit/http.py +0 -0
  15. {ezkit-1.12.2 → ezkit-1.12.3}/ezKit/markdown_to_html.template +0 -0
  16. {ezkit-1.12.2 → ezkit-1.12.3}/ezKit/mongo.py +0 -0
  17. {ezkit-1.12.2 → ezkit-1.12.3}/ezKit/qywx.py +0 -0
  18. {ezkit-1.12.2 → ezkit-1.12.3}/ezKit/redis.py +0 -0
  19. {ezkit-1.12.2 → ezkit-1.12.3}/ezKit/sendemail.py +0 -0
  20. {ezkit-1.12.2 → ezkit-1.12.3}/ezKit/token.py +0 -0
  21. {ezkit-1.12.2 → ezkit-1.12.3}/ezKit/utils.py +0 -0
  22. {ezkit-1.12.2 → ezkit-1.12.3}/ezKit/xftp.py +0 -0
  23. {ezkit-1.12.2 → ezkit-1.12.3}/ezKit/zabbix.py +0 -0
  24. {ezkit-1.12.2 → ezkit-1.12.3}/ezKit.egg-info/SOURCES.txt +0 -0
  25. {ezkit-1.12.2 → ezkit-1.12.3}/ezKit.egg-info/dependency_links.txt +0 -0
  26. {ezkit-1.12.2 → ezkit-1.12.3}/ezKit.egg-info/requires.txt +0 -0
  27. {ezkit-1.12.2 → ezkit-1.12.3}/ezKit.egg-info/top_level.txt +0 -0
  28. {ezkit-1.12.2 → ezkit-1.12.3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ezKit
3
- Version: 1.12.2
3
+ Version: 1.12.3
4
4
  Summary: Easy Kit
5
5
  Author: septvean
6
6
  Author-email: septvean@gmail.com
@@ -8,12 +8,12 @@
8
8
  # https://www.postgresql.org/docs/14/datatype.html
9
9
  import csv
10
10
  import json
11
- from typing import Any
11
+ from typing import Any, Type
12
12
 
13
13
  import pandas as pd
14
14
  from loguru import logger
15
15
  from sqlalchemy import CursorResult, Index, create_engine, text
16
- from sqlalchemy.orm import DeclarativeBase
16
+ from sqlalchemy.orm import DeclarativeBase, Session
17
17
 
18
18
  from . import utils
19
19
 
@@ -346,3 +346,36 @@ class Database:
346
346
  logger.error(f"{info} [failed]")
347
347
  logger.exception(e)
348
348
  return data
349
+
350
+ # ----------------------------------------------------------------------------------------------
351
+
352
+ def create_with_dict_or_list(self, TS: Type, data: dict | list):
353
+ """将 dict 或 list 类型的数据添加到表中. TS: Table Schema"""
354
+
355
+ info: str = "create data"
356
+
357
+ try:
358
+
359
+ logger.info(f"{info} ......")
360
+
361
+ with Session(self.engine) as session:
362
+
363
+ if utils.isTrue(data, dict):
364
+ logger.info(f"{info} [data type is dict]")
365
+ session.add(TS(**data)) # type: ignore
366
+
367
+ if utils.isTrue(data, list):
368
+ logger.info(f"{info} [data type is list]")
369
+ for item in data:
370
+ session.add(TS(**item))
371
+
372
+ session.commit()
373
+
374
+ logger.success(f"{info} [success]")
375
+
376
+ return True
377
+
378
+ except Exception as e:
379
+ logger.error(f"{info} [failed]")
380
+ logger.exception(e)
381
+ return False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ezKit
3
- Version: 1.12.2
3
+ Version: 1.12.3
4
4
  Summary: Easy Kit
5
5
  Author: septvean
6
6
  Author-email: septvean@gmail.com
@@ -4,7 +4,7 @@ from setuptools import find_packages, setup
4
4
 
5
5
  setup(
6
6
  name="ezKit",
7
- version="1.12.2",
7
+ version="1.12.3",
8
8
  author="septvean",
9
9
  author_email="septvean@gmail.com",
10
10
  description="Easy Kit",
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