ezKit 1.6.1__py3-none-any.whl → 1.7.0__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/cipher.py +1 -0
- ezKit/mongo.py +9 -7
- ezKit/utils.py +474 -394
- {ezKit-1.6.1.dist-info → ezKit-1.7.0.dist-info}/METADATA +1 -3
- {ezKit-1.6.1.dist-info → ezKit-1.7.0.dist-info}/RECORD +8 -8
- {ezKit-1.6.1.dist-info → ezKit-1.7.0.dist-info}/WHEEL +1 -1
- {ezKit-1.6.1.dist-info → ezKit-1.7.0.dist-info}/LICENSE +0 -0
- {ezKit-1.6.1.dist-info → ezKit-1.7.0.dist-info}/top_level.txt +0 -0
ezKit/cipher.py
CHANGED
ezKit/mongo.py
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
"""MongoDB"""
|
1
2
|
from loguru import logger
|
2
3
|
from pymongo import MongoClient
|
3
4
|
|
@@ -5,21 +6,19 @@ from . import utils
|
|
5
6
|
|
6
7
|
|
7
8
|
class Mongo():
|
9
|
+
"""MongoDB"""
|
8
10
|
|
9
11
|
client = MongoClient()
|
10
12
|
|
11
|
-
def __init__(self, mongo_url=None):
|
12
|
-
''' Initiation '''
|
13
|
-
if mongo_url != None:
|
14
|
-
self.client = MongoClient(mongo_url)
|
15
|
-
|
16
13
|
def close(self):
|
14
|
+
"""client close"""
|
17
15
|
try:
|
18
16
|
self.client.close()
|
19
17
|
except Exception as e:
|
20
18
|
logger.exception(e)
|
21
19
|
|
22
20
|
def connect_test(self, debug: bool = False):
|
21
|
+
"""client connect test"""
|
23
22
|
info = 'MongoDB连接测试'
|
24
23
|
try:
|
25
24
|
logger.info(f'{info}[执行]')
|
@@ -28,19 +27,22 @@ class Mongo():
|
|
28
27
|
return True
|
29
28
|
except Exception as e:
|
30
29
|
logger.error(f'{info}[失败]')
|
31
|
-
|
30
|
+
if utils.v_true(debug, bool):
|
31
|
+
logger.exception(e)
|
32
32
|
return False
|
33
33
|
|
34
34
|
def collection(self, database, name):
|
35
|
+
"""client collection"""
|
35
36
|
return self.client[database][name]
|
36
37
|
|
37
38
|
def collection_insert(self, database, collection, data, drop=None):
|
39
|
+
"""client collection insert"""
|
38
40
|
db_collection = self.client[database][collection]
|
39
41
|
info = '插入数据'
|
40
42
|
try:
|
41
43
|
logger.info(f'{info}[执行]')
|
42
44
|
# 是否删除 collection
|
43
|
-
if drop
|
45
|
+
if drop is True:
|
44
46
|
# 删除 collection
|
45
47
|
db_collection.drop()
|
46
48
|
# 插入数据
|