mdbq 3.3.4__py3-none-any.whl → 3.3.5__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.
- mdbq/aggregation/query_data.py +2 -2
- mdbq/mysql/mysql.py +22 -22
- {mdbq-3.3.4.dist-info → mdbq-3.3.5.dist-info}/METADATA +1 -1
- {mdbq-3.3.4.dist-info → mdbq-3.3.5.dist-info}/RECORD +6 -6
- {mdbq-3.3.4.dist-info → mdbq-3.3.5.dist-info}/WHEEL +0 -0
- {mdbq-3.3.4.dist-info → mdbq-3.3.5.dist-info}/top_level.txt +0 -0
mdbq/aggregation/query_data.py
CHANGED
@@ -1253,8 +1253,8 @@ class MysqlDatasQuery:
|
|
1253
1253
|
'三级来源索引': 'smallint',
|
1254
1254
|
}
|
1255
1255
|
# df.to_csv('/Users/xigua/Downloads/ll.csv', index=False, header=True, encoding='utf-8_sig')
|
1256
|
-
min_date = df['日期'].min()
|
1257
|
-
max_date = df['日期'].max()
|
1256
|
+
min_date = df['日期'].min().strftime("%Y-%m-%d")
|
1257
|
+
max_date = df['日期'].max().strftime("%Y-%m-%d")
|
1258
1258
|
now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
1259
1259
|
print(f'{now} 正在更新: mysql ({host}:{port}) {db_name}/{table_name} -> {min_date}~{max_date}')
|
1260
1260
|
m_engine.df_to_mysql(
|
mdbq/mysql/mysql.py
CHANGED
@@ -128,7 +128,7 @@ class MysqlUpload:
|
|
128
128
|
|
129
129
|
return wrapper
|
130
130
|
|
131
|
-
def keep_connect(self, _config, max_try: int=5):
|
131
|
+
def keep_connect(self, _db_name, _config, max_try: int=5):
|
132
132
|
attempts = 1
|
133
133
|
while attempts <= max_try:
|
134
134
|
try:
|
@@ -137,8 +137,8 @@ class MysqlUpload:
|
|
137
137
|
except Exception as e:
|
138
138
|
print(f'连接失败,正在重试: {attempts}/{max_try} {e}')
|
139
139
|
attempts += 1
|
140
|
-
time.sleep(
|
141
|
-
print(f'
|
140
|
+
time.sleep(20)
|
141
|
+
print(f'{_db_name}: 连接失败,重试次数超限,当前设定次数: {max_try}')
|
142
142
|
return None
|
143
143
|
|
144
144
|
def cover_doc_dtypes(self, dict_data):
|
@@ -215,7 +215,7 @@ class MysqlUpload:
|
|
215
215
|
return
|
216
216
|
|
217
217
|
# connection = pymysql.connect(**self.config) # 连接数据库
|
218
|
-
connection = self.keep_connect(_config=self.config, max_try=5)
|
218
|
+
connection = self.keep_connect(_db_name=db_name, _config=self.config, max_try=5)
|
219
219
|
if not connection:
|
220
220
|
return
|
221
221
|
with connection.cursor() as cursor:
|
@@ -236,7 +236,7 @@ class MysqlUpload:
|
|
236
236
|
|
237
237
|
self.config.update({'database': db_name}) # 添加更新 config 字段
|
238
238
|
# connection = pymysql.connect(**self.config) # 重新连接数据库
|
239
|
-
connection = self.keep_connect(_config=self.config, max_try=5)
|
239
|
+
connection = self.keep_connect(_db_name=db_name, _config=self.config, max_try=5)
|
240
240
|
if not connection:
|
241
241
|
return
|
242
242
|
with connection.cursor() as cursor:
|
@@ -382,7 +382,7 @@ class MysqlUpload:
|
|
382
382
|
print(f'{table_name} 将数据按年/月保存(cut_data),但在转换日期时报错 -> {e}')
|
383
383
|
|
384
384
|
# connection = pymysql.connect(**self.config) # 连接数据库
|
385
|
-
connection = self.keep_connect(_config=self.config, max_try=5)
|
385
|
+
connection = self.keep_connect(_db_name=db_name, _config=self.config, max_try=5)
|
386
386
|
if not connection:
|
387
387
|
return
|
388
388
|
with connection.cursor() as cursor:
|
@@ -403,7 +403,7 @@ class MysqlUpload:
|
|
403
403
|
|
404
404
|
self.config.update({'database': db_name}) # 添加更新 config 字段
|
405
405
|
# connection = pymysql.connect(**self.config) # 重新连接数据库
|
406
|
-
connection = self.keep_connect(_config=self.config, max_try=5)
|
406
|
+
connection = self.keep_connect(_db_name=db_name, _config=self.config, max_try=5)
|
407
407
|
if not connection:
|
408
408
|
return
|
409
409
|
with connection.cursor() as cursor:
|
@@ -749,7 +749,7 @@ class MysqlUpload:
|
|
749
749
|
[dtypes.update({k: inside_v}) for inside_k, inside_v in set_typ.items() if k == inside_k]
|
750
750
|
|
751
751
|
# connection = pymysql.connect(**self.config) # 连接数据库
|
752
|
-
connection = self.keep_connect(_config=self.config, max_try=5)
|
752
|
+
connection = self.keep_connect(_db_name=db_name, _config=self.config, max_try=5)
|
753
753
|
if not connection:
|
754
754
|
return
|
755
755
|
with connection.cursor() as cursor:
|
@@ -770,7 +770,7 @@ class MysqlUpload:
|
|
770
770
|
|
771
771
|
self.config.update({'database': db_name}) # 添加更新 config 字段
|
772
772
|
# connection = pymysql.connect(**self.config) # 重新连接数据库
|
773
|
-
connection = self.keep_connect(_config=self.config, max_try=5)
|
773
|
+
connection = self.keep_connect(_db_name=db_name, _config=self.config, max_try=5)
|
774
774
|
if not connection:
|
775
775
|
return
|
776
776
|
with connection.cursor() as cursor:
|
@@ -1049,7 +1049,7 @@ class MysqlUpload:
|
|
1049
1049
|
print(f'未指定文件名: filename')
|
1050
1050
|
return
|
1051
1051
|
# connection = pymysql.connect(**self.config) # 连接数据库
|
1052
|
-
connection = self.keep_connect(_config=self.config, max_try=5)
|
1052
|
+
connection = self.keep_connect(_db_name=db_name, _config=self.config, max_try=5)
|
1053
1053
|
if not connection:
|
1054
1054
|
return
|
1055
1055
|
# try:
|
@@ -1061,7 +1061,7 @@ class MysqlUpload:
|
|
1061
1061
|
return
|
1062
1062
|
self.config.update({'database': db_name})
|
1063
1063
|
# connection = pymysql.connect(**self.config) # 重新连接数据库
|
1064
|
-
connection = self.keep_connect(_config=self.config, max_try=5)
|
1064
|
+
connection = self.keep_connect(_db_name=db_name, _config=self.config, max_try=5)
|
1065
1065
|
if not connection:
|
1066
1066
|
return
|
1067
1067
|
with connection.cursor() as cursor:
|
@@ -1094,7 +1094,7 @@ class MysqlUpload:
|
|
1094
1094
|
df = pd.DataFrame()
|
1095
1095
|
|
1096
1096
|
# connection = pymysql.connect(**self.config) # 连接数据库
|
1097
|
-
connection = self.keep_connect(_config=self.config, max_try=5)
|
1097
|
+
connection = self.keep_connect(_db_name=db_name, _config=self.config, max_try=5)
|
1098
1098
|
if not connection:
|
1099
1099
|
return
|
1100
1100
|
try:
|
@@ -1116,7 +1116,7 @@ class MysqlUpload:
|
|
1116
1116
|
# 读取数据
|
1117
1117
|
self.config.update({'database': db_name})
|
1118
1118
|
# connection = pymysql.connect(**self.config) # 重新连接数据库
|
1119
|
-
connection = self.keep_connect(_config=self.config, max_try=5)
|
1119
|
+
connection = self.keep_connect(_db_name=db_name, _config=self.config, max_try=5)
|
1120
1120
|
if not connection:
|
1121
1121
|
return
|
1122
1122
|
try:
|
@@ -1240,7 +1240,7 @@ class OptimizeDatas:
|
|
1240
1240
|
|
1241
1241
|
return wrapper
|
1242
1242
|
|
1243
|
-
def keep_connect(self, _config, max_try: int=5):
|
1243
|
+
def keep_connect(self, _db_name, _config, max_try: int=5):
|
1244
1244
|
attempts = 1
|
1245
1245
|
while attempts <= max_try:
|
1246
1246
|
try:
|
@@ -1249,8 +1249,8 @@ class OptimizeDatas:
|
|
1249
1249
|
except Exception as e:
|
1250
1250
|
print(f'连接失败,正在重试: {attempts}/{max_try} {e}')
|
1251
1251
|
attempts += 1
|
1252
|
-
time.sleep(
|
1253
|
-
print(f'
|
1252
|
+
time.sleep(20)
|
1253
|
+
print(f'{_db_name}: 连接失败,重试次数超限,当前设定次数: {max_try}')
|
1254
1254
|
return None
|
1255
1255
|
|
1256
1256
|
def optimize_list(self):
|
@@ -1300,7 +1300,7 @@ class OptimizeDatas:
|
|
1300
1300
|
# continue
|
1301
1301
|
self.config.update({'database': self.db_name}) # 添加更新 config 字段
|
1302
1302
|
# self.connection = pymysql.connect(**self.config)
|
1303
|
-
self.connection = self.keep_connect(_config=self.config, max_try=5)
|
1303
|
+
self.connection = self.keep_connect(_db_name=self.db_name, _config=self.config, max_try=5)
|
1304
1304
|
if not self.connection:
|
1305
1305
|
return
|
1306
1306
|
with self.connection.cursor() as cursor:
|
@@ -1455,7 +1455,7 @@ class OptimizeDatas:
|
|
1455
1455
|
def database_list(self):
|
1456
1456
|
""" 获取所有数据库 """
|
1457
1457
|
# connection = pymysql.connect(**self.config) # 连接数据库
|
1458
|
-
connection = self.keep_connect(_config=self.config, max_try=5)
|
1458
|
+
connection = self.keep_connect(_db_name=self.db_name, _config=self.config, max_try=5)
|
1459
1459
|
if not connection:
|
1460
1460
|
return
|
1461
1461
|
with connection.cursor() as cursor:
|
@@ -1467,7 +1467,7 @@ class OptimizeDatas:
|
|
1467
1467
|
def table_list(self, db_name):
|
1468
1468
|
""" 获取指定数据库的所有数据表 """
|
1469
1469
|
# connection = pymysql.connect(**self.config) # 连接数据库
|
1470
|
-
connection = self.keep_connect(_config=self.config, max_try=5)
|
1470
|
+
connection = self.keep_connect(_db_name=self.db_name, _config=self.config, max_try=5)
|
1471
1471
|
if not connection:
|
1472
1472
|
return
|
1473
1473
|
try:
|
@@ -1486,7 +1486,7 @@ class OptimizeDatas:
|
|
1486
1486
|
|
1487
1487
|
self.config.update({'database': db_name}) # 添加更新 config 字段
|
1488
1488
|
# connection = pymysql.connect(**self.config) # 重新连接数据库
|
1489
|
-
connection = self.keep_connect(_config=self.config, max_try=5)
|
1489
|
+
connection = self.keep_connect(_db_name=db_name, _config=self.config, max_try=5)
|
1490
1490
|
if not connection:
|
1491
1491
|
return
|
1492
1492
|
with connection.cursor() as cursor:
|
@@ -1501,7 +1501,7 @@ class OptimizeDatas:
|
|
1501
1501
|
"""
|
1502
1502
|
self.config.update({'database': db_name}) # 添加更新 config 字段
|
1503
1503
|
# connection = pymysql.connect(**self.config)
|
1504
|
-
connection = self.keep_connect(_config=self.config, max_try=5)
|
1504
|
+
connection = self.keep_connect(_db_name=db_name, _config=self.config, max_try=5)
|
1505
1505
|
if not connection:
|
1506
1506
|
return
|
1507
1507
|
try:
|
@@ -1537,7 +1537,7 @@ class OptimizeDatas:
|
|
1537
1537
|
for key, table_name in table_dict.items():
|
1538
1538
|
self.config.update({'database': self.db_name}) # 添加更新 config 字段
|
1539
1539
|
# self.connection = pymysql.connect(**self.config)
|
1540
|
-
self.connection = self.keep_connect(_config=self.config, max_try=5)
|
1540
|
+
self.connection = self.keep_connect(_db_name=self.db_name, _config=self.config, max_try=5)
|
1541
1541
|
if not self.connection:
|
1542
1542
|
return
|
1543
1543
|
with self.connection.cursor() as cursor:
|
@@ -5,7 +5,7 @@ mdbq/aggregation/aggregation.py,sha256=-yzApnlqSN2L0E1YMu5ml-W827qpKQvWPCOI7jj2k
|
|
5
5
|
mdbq/aggregation/df_types.py,sha256=U9i3q2eRPTDY8qAPTw7irzu-Tlg4CIySW9uYro81wdk,8125
|
6
6
|
mdbq/aggregation/mysql_types.py,sha256=YTGyrF9vcRgfkQbpT-e-JdJ7c7VF1dDHgyx9YZRES8w,10934
|
7
7
|
mdbq/aggregation/optimize_data.py,sha256=RXIv7cACCgYyehAxMjUYi_S7rVyjIwXKWMaM3nduGtA,3068
|
8
|
-
mdbq/aggregation/query_data.py,sha256=
|
8
|
+
mdbq/aggregation/query_data.py,sha256=_5mnSFHV6xAFs_1YF_H2zMOdJeMavgga4lZQ_qpqxPQ,167637
|
9
9
|
mdbq/bdup/__init__.py,sha256=AkhsGk81SkG1c8FqDH5tRq-8MZmFobVbN60DTyukYTY,28
|
10
10
|
mdbq/bdup/bdup.py,sha256=LAV0TgnQpc-LB-YuJthxb0U42_VkPidzQzAagan46lU,4234
|
11
11
|
mdbq/clean/__init__.py,sha256=A1d6x3L27j4NtLgiFV5TANwEkLuaDfPHDQNrPBbNWtU,41
|
@@ -26,7 +26,7 @@ mdbq/log/mylogger.py,sha256=oaT7Bp-Hb9jZt52seP3ISUuxVcI19s4UiqTeouScBO0,3258
|
|
26
26
|
mdbq/mongo/__init__.py,sha256=SILt7xMtQIQl_m-ik9WLtJSXIVf424iYgCfE_tnQFbw,13
|
27
27
|
mdbq/mongo/mongo.py,sha256=v9qvrp6p1ZRWuPpbSilqveiE0FEcZF7U5xUPI0RN4xs,31880
|
28
28
|
mdbq/mysql/__init__.py,sha256=A_DPJyAoEvTSFojiI2e94zP0FKtCkkwKP1kYUCSyQzo,11
|
29
|
-
mdbq/mysql/mysql.py,sha256=
|
29
|
+
mdbq/mysql/mysql.py,sha256=ZK6E-idQWrURtoimc0uG8B1tnhtSFQXDJHfu8sWeJg4,85675
|
30
30
|
mdbq/mysql/recheck_mysql.py,sha256=rgTpvDMWYTyEn7UQdlig-pdXDluTgiU8JG6lkMh8DV0,8665
|
31
31
|
mdbq/mysql/s_query.py,sha256=MbIprZ4yJDAZ9AahZPzl7hqS695Vs0P-AJNwAtA_EEc,9287
|
32
32
|
mdbq/mysql/year_month_day.py,sha256=VgewoE2pJxK7ErjfviL_SMTN77ki8GVbTUcao3vFUCE,1523
|
@@ -44,7 +44,7 @@ mdbq/req_post/__init__.py,sha256=jso1oHcy6cJEfa7udS_9uO5X6kZLoPBF8l3wCYmr5dM,18
|
|
44
44
|
mdbq/req_post/req_tb.py,sha256=qg7pet73IgKGmCwxaeUyImJIoeK_pBQT9BBKD7fkBNg,36160
|
45
45
|
mdbq/spider/__init__.py,sha256=RBMFXGy_jd1HXZhngB2T2XTvJqki8P_Fr-pBcwijnew,18
|
46
46
|
mdbq/spider/aikucun.py,sha256=BKVa0xbTkyhIH5kQgOdyPDtwFPScbMNAFYup_-fFF9Y,24809
|
47
|
-
mdbq-3.3.
|
48
|
-
mdbq-3.3.
|
49
|
-
mdbq-3.3.
|
50
|
-
mdbq-3.3.
|
47
|
+
mdbq-3.3.5.dist-info/METADATA,sha256=ndDUyzoqoEH--Mhw_0Z7xXEPTwWuLyBkT8jsfUx8AxA,243
|
48
|
+
mdbq-3.3.5.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
49
|
+
mdbq-3.3.5.dist-info/top_level.txt,sha256=2FQ-uLnCSB-OwFiWntzmwosW3X2Xqsg0ewh1axsaylA,5
|
50
|
+
mdbq-3.3.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|