re-common 10.0.32__py3-none-any.whl → 10.0.33__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.
- re_common/v2/baselibrary/utils/db.py +27 -25
- {re_common-10.0.32.dist-info → re_common-10.0.33.dist-info}/METADATA +1 -1
- {re_common-10.0.32.dist-info → re_common-10.0.33.dist-info}/RECORD +6 -6
- {re_common-10.0.32.dist-info → re_common-10.0.33.dist-info}/LICENSE +0 -0
- {re_common-10.0.32.dist-info → re_common-10.0.33.dist-info}/WHEEL +0 -0
- {re_common-10.0.32.dist-info → re_common-10.0.33.dist-info}/top_level.txt +0 -0
|
@@ -1,38 +1,40 @@
|
|
|
1
|
-
import atexit
|
|
2
1
|
import os
|
|
2
|
+
import aiomysql
|
|
3
|
+
import asyncio
|
|
3
4
|
from contextlib import asynccontextmanager
|
|
4
5
|
from typing import AsyncGenerator, Tuple
|
|
5
6
|
|
|
6
7
|
from aiomysql import Pool, Connection, Cursor
|
|
7
8
|
|
|
8
9
|
DB_CONFIG = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
"host": "192.168.98.64",
|
|
11
|
+
"port": 4000,
|
|
12
|
+
"user": "dataware_house_baseUser",
|
|
13
|
+
"password": "FF19AF831AEBD580B450B16BF9264200",
|
|
14
|
+
"db": "dataware_house_base",
|
|
15
|
+
"charset": "utf8mb4",
|
|
16
|
+
"minsize": 16, # 最小连接数
|
|
17
|
+
"maxsize": 128, # 最大连接数
|
|
18
|
+
"autocommit": False, # 自动提交事务
|
|
19
|
+
"pool_recycle": 3600, # 每个连接的回收时间(秒),超过此时间后连接将被关闭并重新创建,避免失效连接
|
|
20
|
+
"echo": False, # 打印SQL语句
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
DB_CONFIG1 = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
"host": "192.168.98.64",
|
|
25
|
+
"port": 4000,
|
|
26
|
+
"user": "foreign_fulltextUser",
|
|
27
|
+
"password": "i4hIeasw1qpmhGN2nwL7",
|
|
28
|
+
"db": "foreign_fulltext",
|
|
29
|
+
"charset": "utf8mb4",
|
|
30
|
+
"minsize": 16, # 最小连接数
|
|
31
|
+
"maxsize": 128, # 最大连接数
|
|
32
|
+
"autocommit": False, # 自动提交事务
|
|
33
|
+
"pool_recycle": 3600, # 每个连接的回收时间(秒),超过此时间后连接将被关闭并重新创建,避免失效连接
|
|
34
|
+
"echo": False, # 打印SQL语句
|
|
34
35
|
}
|
|
35
36
|
|
|
37
|
+
|
|
36
38
|
async def get_pool_only(_DB_CONFIG: dict = None):
|
|
37
39
|
global DB_CONFIG
|
|
38
40
|
if _DB_CONFIG is not None:
|
|
@@ -40,6 +42,7 @@ async def get_pool_only(_DB_CONFIG: dict = None):
|
|
|
40
42
|
pool: Pool = await aiomysql.create_pool(**DB_CONFIG)
|
|
41
43
|
return pool
|
|
42
44
|
|
|
45
|
+
|
|
43
46
|
@asynccontextmanager
|
|
44
47
|
async def get_db_pool(_DB_CONFIG: dict = None):
|
|
45
48
|
"""异步数据库连接池管理工具"""
|
|
@@ -63,8 +66,7 @@ async def get_session(pool: Pool) -> AsyncGenerator[Tuple[Connection, Cursor], N
|
|
|
63
66
|
|
|
64
67
|
|
|
65
68
|
# main.py
|
|
66
|
-
|
|
67
|
-
import asyncio
|
|
69
|
+
|
|
68
70
|
|
|
69
71
|
aiomysql_pool = None
|
|
70
72
|
pool_lock = asyncio.Lock() # 全局异步锁
|
|
@@ -202,7 +202,7 @@ re_common/v2/baselibrary/utils/basedict.py,sha256=sH3_RZ8u4649-jX2V1uKNNkjJVUijZ
|
|
|
202
202
|
re_common/v2/baselibrary/utils/basehdfs.py,sha256=TPwFct_-UrmO1KCbo4gpV77rsnlCQDumNBbQKL0ZI9o,5953
|
|
203
203
|
re_common/v2/baselibrary/utils/basepika.py,sha256=ifOb3UsGj79k40aD9UK6-5BMPw43ZAo0SO3AYD4q4vw,7332
|
|
204
204
|
re_common/v2/baselibrary/utils/basetime.py,sha256=b7U_ho6nE3fjYBxSkdMHXUOd3ClH6KkW_7p7l2Gs4gA,3038
|
|
205
|
-
re_common/v2/baselibrary/utils/db.py,sha256=
|
|
205
|
+
re_common/v2/baselibrary/utils/db.py,sha256=SdrLIhijgXUsXQL2aStQS-NgnAfWMvfn8RHEyqdoezI,2500
|
|
206
206
|
re_common/v2/baselibrary/utils/json_cls.py,sha256=M93piYtmgm_wP8E57culTrd_AhHLoGg6PqeAJYdW2SM,438
|
|
207
207
|
re_common/v2/baselibrary/utils/mq.py,sha256=UHpO8iNIHs91Tgp-BgnSUpZwjWquxrGLdpr3FMMv2zw,2858
|
|
208
208
|
re_common/v2/baselibrary/utils/n_ary_expression_tree.py,sha256=-05kO6G2Rth7CEK-5lfFrthFZ1Q0-0a7cni7mWZ-2gg,9172
|
|
@@ -236,8 +236,8 @@ re_common/vip/title/transform/TransformRegulationTitleToZt.py,sha256=LKRdIsWKues
|
|
|
236
236
|
re_common/vip/title/transform/TransformStandardTitleToZt.py,sha256=-fCKAbSBzXVyQDCE61CalvR9E_QzQMA08QOO_NePFNI,5563
|
|
237
237
|
re_common/vip/title/transform/TransformThesisTitleToZt.py,sha256=QS-uV0cQrpUFAcKucuJQ9Ue2VRQH-inmfn_X3IplfRo,5488
|
|
238
238
|
re_common/vip/title/transform/__init__.py,sha256=m83-CWyRq_VHPYHaALEQlmXrkTdrZ3e4B_kCfBYE-uc,239
|
|
239
|
-
re_common-10.0.
|
|
240
|
-
re_common-10.0.
|
|
241
|
-
re_common-10.0.
|
|
242
|
-
re_common-10.0.
|
|
243
|
-
re_common-10.0.
|
|
239
|
+
re_common-10.0.33.dist-info/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
|
|
240
|
+
re_common-10.0.33.dist-info/METADATA,sha256=bmraxgArGm6vGU0k3cC6EfoOY_T0SYZnuL-XVAIhI90,764
|
|
241
|
+
re_common-10.0.33.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
242
|
+
re_common-10.0.33.dist-info/top_level.txt,sha256=_H9H23zoLIalm1AIY_KYTVh_H0ZnmjxQIxsvXtLv45o,10
|
|
243
|
+
re_common-10.0.33.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|