xtn-tools-pro 1.0.1.4.6__py3-none-any.whl → 1.0.1.4.8__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.
- xtn_tools_pro/db/RedisDB.py +12 -4
- {xtn_tools_pro-1.0.1.4.6.dist-info → xtn_tools_pro-1.0.1.4.8.dist-info}/METADATA +1 -1
- {xtn_tools_pro-1.0.1.4.6.dist-info → xtn_tools_pro-1.0.1.4.8.dist-info}/RECORD +7 -7
- {xtn_tools_pro-1.0.1.4.6.dist-info → xtn_tools_pro-1.0.1.4.8.dist-info}/LICENSE +0 -0
- {xtn_tools_pro-1.0.1.4.6.dist-info → xtn_tools_pro-1.0.1.4.8.dist-info}/WHEEL +0 -0
- {xtn_tools_pro-1.0.1.4.6.dist-info → xtn_tools_pro-1.0.1.4.8.dist-info}/entry_points.txt +0 -0
- {xtn_tools_pro-1.0.1.4.6.dist-info → xtn_tools_pro-1.0.1.4.8.dist-info}/top_level.txt +0 -0
xtn_tools_pro/db/RedisDB.py
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
# --------------------------------------------------------------------------------------------------
|
|
9
9
|
# 2024/4/18 xiatn V00.01.000 新建
|
|
10
10
|
# --------------------------------------------------------------------------------------------------
|
|
11
|
+
import json
|
|
11
12
|
import time
|
|
12
13
|
import redis
|
|
13
14
|
from redis import Redis
|
|
@@ -27,7 +28,8 @@ class RedisDBPro:
|
|
|
27
28
|
self._max_connections = max_connections # 同一个redis对象使用的并发数(连接池的最大连接数),超过这个数量会抛出redis.ConnectionError
|
|
28
29
|
self._kwargs = kwargs
|
|
29
30
|
# 连接
|
|
30
|
-
self.__redis: Optional[Redis] = None
|
|
31
|
+
# self.__redis: Optional[Redis] = None
|
|
32
|
+
self.__redis = None
|
|
31
33
|
self.get_connect()
|
|
32
34
|
|
|
33
35
|
def __del__(self):
|
|
@@ -188,16 +190,21 @@ class RedisDBPro:
|
|
|
188
190
|
"""
|
|
189
191
|
return self._redis.hset(name=table, key=key, value=value, mapping=mapping)
|
|
190
192
|
|
|
191
|
-
def hget(self,name,key):
|
|
193
|
+
def hget(self, name, key, is_json=False):
|
|
192
194
|
"""
|
|
193
195
|
读单个
|
|
194
196
|
:param name: 表
|
|
195
197
|
:param key: key
|
|
198
|
+
:param is_json: True 会转为json
|
|
196
199
|
:return:
|
|
197
200
|
"""
|
|
198
|
-
|
|
201
|
+
data = self._redis.hget(name, key)
|
|
202
|
+
if not is_json:
|
|
203
|
+
return data
|
|
204
|
+
json_data = json.loads(data)
|
|
205
|
+
return json_data
|
|
199
206
|
|
|
200
|
-
def hgetall(self,name):
|
|
207
|
+
def hgetall(self, name):
|
|
201
208
|
"""
|
|
202
209
|
读全部字段(小 Hash 可用,大 Hash 慎用)
|
|
203
210
|
:param name:
|
|
@@ -205,6 +212,7 @@ class RedisDBPro:
|
|
|
205
212
|
"""
|
|
206
213
|
return self._redis.hgetall(name)
|
|
207
214
|
|
|
215
|
+
|
|
208
216
|
if __name__ == '__main__':
|
|
209
217
|
pass
|
|
210
218
|
# r = RedisDBPro(ip="127.0.0.1", port=6379, db=0, user_pass="xtn-kk")
|
|
@@ -7,7 +7,7 @@ xtn_tools_pro/data/__init__.py,sha256=Cg6fMz1PlSjPa1LUyQtpzvvjvFdxiky_PjxaNFr3wI
|
|
|
7
7
|
xtn_tools_pro/data/set_data_pro.py,sha256=Cg6fMz1PlSjPa1LUyQtpzvvjvFdxiky_PjxaNFr3wIo,418
|
|
8
8
|
xtn_tools_pro/db/MongoDB.py,sha256=CljtA5NnutOPL0j2ClrCE4RXW-9N_306D3PAdRANmuk,5699
|
|
9
9
|
xtn_tools_pro/db/MysqlDB.py,sha256=SBJrcjbZdxmtTKPGwl57NthPhs4uX8J3P6o_rK01O4k,13373
|
|
10
|
-
xtn_tools_pro/db/RedisDB.py,sha256=
|
|
10
|
+
xtn_tools_pro/db/RedisDB.py,sha256=MV2pIynq8X8SqcKErxDx_1nOq9pBODlh8O6cu5mkU5U,7650
|
|
11
11
|
xtn_tools_pro/db/__init__.py,sha256=Zg91UWS02TO0Ba_0AY56s0oabRy93xLNFkpIIL_6mMM,416
|
|
12
12
|
xtn_tools_pro/flask_demo/__init__.py,sha256=2hSMIjKC8-T_9aTJU35DjkwWKa1-ZzMgwfFajs69TWI,418
|
|
13
13
|
xtn_tools_pro/flask_demo/cli.py,sha256=wBcdWu5uN1QB8begyGHnhSln4IiZJPTFE8CDy0sQGTk,3116
|
|
@@ -70,9 +70,9 @@ xtn_tools_pro/utils/shell.py,sha256=s6sJedxLLQokcI1hF5YSD3qgGUPK0brNcP-D3-yv54I,
|
|
|
70
70
|
xtn_tools_pro/utils/sql.py,sha256=EAKzbkZP7Q09j15Gm6o0_uq0qgQmcCQT6EAawbpp4v0,6263
|
|
71
71
|
xtn_tools_pro/utils/time_utils.py,sha256=TUtzG61PeVYXhaQd6pBrXAdlz7tBispNIRQRcGhE2No,4859
|
|
72
72
|
xtn_tools_pro/utils/win.py,sha256=D5_58WMKOGe9ZwJuJr2JGAWmVISwMOZUx4t7wXUCviU,3512
|
|
73
|
-
xtn_tools_pro-1.0.1.4.
|
|
74
|
-
xtn_tools_pro-1.0.1.4.
|
|
75
|
-
xtn_tools_pro-1.0.1.4.
|
|
76
|
-
xtn_tools_pro-1.0.1.4.
|
|
77
|
-
xtn_tools_pro-1.0.1.4.
|
|
78
|
-
xtn_tools_pro-1.0.1.4.
|
|
73
|
+
xtn_tools_pro-1.0.1.4.8.dist-info/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
74
|
+
xtn_tools_pro-1.0.1.4.8.dist-info/METADATA,sha256=p8g8YdQ2kk4q20U4HRlc5KWgIbhhtUHjztCklrDkO8I,597
|
|
75
|
+
xtn_tools_pro-1.0.1.4.8.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
76
|
+
xtn_tools_pro-1.0.1.4.8.dist-info/entry_points.txt,sha256=t8CtXWOgw7nRDW3XNlZh8MT_P4l8EzsFnyWi5b3ovrc,68
|
|
77
|
+
xtn_tools_pro-1.0.1.4.8.dist-info/top_level.txt,sha256=jyB3FLDEr8zE1U7wHczTgIbvUpALhR-ULF7RVEO7O2U,14
|
|
78
|
+
xtn_tools_pro-1.0.1.4.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|