mdbq 4.1.1__tar.gz → 4.1.2__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.
Potentially problematic release.
This version of mdbq might be problematic. Click here for more details.
- {mdbq-4.1.1 → mdbq-4.1.2}/PKG-INFO +1 -1
- mdbq-4.1.2/mdbq/__version__.py +1 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/mysql/deduplicator.py +11 -11
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/mysql/uploader.py +9 -9
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq.egg-info/PKG-INFO +1 -1
- mdbq-4.1.1/mdbq/__version__.py +0 -1
- {mdbq-4.1.1 → mdbq-4.1.2}/README.txt +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/__init__.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/auth/__init__.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/auth/auth_backend.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/auth/crypto.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/auth/rate_limiter.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/js/__init__.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/js/jc.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/log/__init__.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/log/mylogger.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/myconf/__init__.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/myconf/myconf.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/mysql/__init__.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/mysql/mysql.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/mysql/s_query.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/mysql/unique_.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/other/__init__.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/other/download_sku_picture.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/other/error_handler.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/other/otk.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/other/pov_city.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/other/ua_sj.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/pbix/__init__.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/pbix/pbix_refresh.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/pbix/refresh_all.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/redis/__init__.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/redis/getredis.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/redis/redis_cache.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/route/__init__.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/route/analytics.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/route/monitor.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/route/routes.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/selenium/__init__.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/selenium/get_driver.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq/spider/__init__.py +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq.egg-info/SOURCES.txt +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq.egg-info/dependency_links.txt +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/mdbq.egg-info/top_level.txt +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/setup.cfg +0 -0
- {mdbq-4.1.1 → mdbq-4.1.2}/setup.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VERSION = '4.1.2'
|
|
@@ -168,7 +168,7 @@ class MySQLDeduplicator:
|
|
|
168
168
|
self._dedup_end_date = today.strftime("%Y-%m-%d")
|
|
169
169
|
|
|
170
170
|
if self._dedup_start_date and self._dedup_end_date:
|
|
171
|
-
logger.
|
|
171
|
+
logger.debug('去重日期范围', {'开始': self._dedup_start_date, '结束': self._dedup_end_date})
|
|
172
172
|
|
|
173
173
|
# 排除列处理,直接合并去重
|
|
174
174
|
self.exclude_columns = list(set((exclude_columns or []) + ['id', '更新时间']))
|
|
@@ -515,7 +515,7 @@ class MySQLDeduplicator:
|
|
|
515
515
|
dup_count_row = cursor.fetchone()
|
|
516
516
|
dup_count = dup_count_row['cnt'] if dup_count_row and 'cnt' in dup_count_row else 0
|
|
517
517
|
if dup_count == 0:
|
|
518
|
-
logger.
|
|
518
|
+
logger.debug('没有重复数据', {"库": database, "表": table, "数据量": total_count, "数据日期": date_val})
|
|
519
519
|
cursor.execute(drop_temp_sql)
|
|
520
520
|
conn.commit()
|
|
521
521
|
return (0, 0)
|
|
@@ -626,7 +626,7 @@ class MySQLDeduplicator:
|
|
|
626
626
|
dup_count_row = cursor.fetchone()
|
|
627
627
|
dup_count = dup_count_row['cnt'] if dup_count_row and 'cnt' in dup_count_row else 0
|
|
628
628
|
if dup_count == 0:
|
|
629
|
-
logger.
|
|
629
|
+
logger.debug('没有重复数据', {"库": database, "表": table, "数据量": total_count})
|
|
630
630
|
cursor.execute(drop_temp_sql)
|
|
631
631
|
conn.commit()
|
|
632
632
|
return (0, 0)
|
|
@@ -722,7 +722,7 @@ class MySQLDeduplicator:
|
|
|
722
722
|
if not self._check_table_exists(database, table):
|
|
723
723
|
logger.warning('表不存在', {"库": database, "表": table, "warning": "跳过"})
|
|
724
724
|
return (0, 0)
|
|
725
|
-
logger.
|
|
725
|
+
logger.debug('单表开始', {
|
|
726
726
|
"库": database,
|
|
727
727
|
"表": table,
|
|
728
728
|
# "参数": {
|
|
@@ -763,7 +763,7 @@ class MySQLDeduplicator:
|
|
|
763
763
|
if start_date and end_date:
|
|
764
764
|
all_dates = [d for d in all_dates if str(start_date) <= str(d) <= str(end_date)]
|
|
765
765
|
if not all_dates:
|
|
766
|
-
logger.
|
|
766
|
+
logger.debug('无可处理日期', {"库": database, "表": table})
|
|
767
767
|
return (0, 0)
|
|
768
768
|
total_dup = 0
|
|
769
769
|
total_del = 0
|
|
@@ -794,7 +794,7 @@ class MySQLDeduplicator:
|
|
|
794
794
|
logger.warning('分区处理失败', {"库": database, "表": table, "日期": date_val, "异常": err, "func": sys._getframe().f_code.co_name})
|
|
795
795
|
total_dup += dup_count
|
|
796
796
|
total_del += affected_rows
|
|
797
|
-
logger.
|
|
797
|
+
logger.debug('单表完成', {"库": database, "表": table, "结果[重复, 删除]": (total_dup, total_del), '日期范围': f"{start_date} - {end_date}", "唯一列": columns})
|
|
798
798
|
# 自动重排id列(仅当有实际删除时且reorder_id为True)
|
|
799
799
|
if reorder_id and total_del > 0:
|
|
800
800
|
try:
|
|
@@ -858,7 +858,7 @@ class MySQLDeduplicator:
|
|
|
858
858
|
if not target_tables:
|
|
859
859
|
logger.info('数据库中没有表', {"库": database, "操作": "跳过"})
|
|
860
860
|
return results
|
|
861
|
-
logger.
|
|
861
|
+
logger.debug('库统计', {"库": database, "表数量": len(target_tables), "表列表": target_tables})
|
|
862
862
|
if parallel and self.max_workers > 1:
|
|
863
863
|
with concurrent.futures.ThreadPoolExecutor(
|
|
864
864
|
max_workers=self.max_workers
|
|
@@ -1073,9 +1073,9 @@ class MySQLDeduplicator:
|
|
|
1073
1073
|
if hasattr(self, 'pool') and self.pool and not self._closed:
|
|
1074
1074
|
self.pool.close()
|
|
1075
1075
|
self._closed = True
|
|
1076
|
-
logger.
|
|
1076
|
+
logger.debug("数据库连接池已关闭")
|
|
1077
1077
|
else:
|
|
1078
|
-
logger.
|
|
1078
|
+
logger.debug('连接池已关闭或不存在')
|
|
1079
1079
|
except Exception as e:
|
|
1080
1080
|
logger.error(f"关闭连接池时出错", {'error_type': type(e).__name__, 'error': str(e)})
|
|
1081
1081
|
|
|
@@ -1172,7 +1172,7 @@ class MySQLDeduplicator:
|
|
|
1172
1172
|
with conn.cursor() as cursor:
|
|
1173
1173
|
cursor.execute(f"SHOW CREATE TABLE {table_quoted}")
|
|
1174
1174
|
create_table_sql = cursor.fetchone()['Create Table']
|
|
1175
|
-
logger.
|
|
1175
|
+
logger.debug('开始id重排', {"库": database, "表": table, "重排列": id_column, "试运行": dry_run, "DDL警告": "MySQL DDL操作不可回滚,建议提前备份!"})
|
|
1176
1176
|
if dry_run:
|
|
1177
1177
|
logger.info('dry_run模式,打印原表结构', {"库": database, "表": table, "建表语句": create_table_sql})
|
|
1178
1178
|
return True
|
|
@@ -1370,7 +1370,7 @@ def main():
|
|
|
1370
1370
|
# recent_month=1,
|
|
1371
1371
|
# date_range=['2025-06-09', '2025-06-10'],
|
|
1372
1372
|
exclude_columns=['更新时间'],
|
|
1373
|
-
exclude_databases=['cookie文件', '日志', '视频数据', '云电影'
|
|
1373
|
+
exclude_databases=['cookie文件', '日志', '视频数据', '云电影'],
|
|
1374
1374
|
# exclude_tables={
|
|
1375
1375
|
# '推广数据2': [
|
|
1376
1376
|
# '地域报表_城市_2025_04',
|
|
@@ -199,7 +199,7 @@ class MySQLUploader:
|
|
|
199
199
|
try:
|
|
200
200
|
result = func(self, *args, **kwargs)
|
|
201
201
|
if attempt > 0:
|
|
202
|
-
logger.
|
|
202
|
+
logger.debug('操作成功(重试后)', {'operation': operation, 'attempts': attempt + 1})
|
|
203
203
|
return result
|
|
204
204
|
except (pymysql.OperationalError, pymysql.err.MySQLError) as e:
|
|
205
205
|
last_exception = e
|
|
@@ -217,7 +217,7 @@ class MySQLUploader:
|
|
|
217
217
|
time.sleep(wait_time)
|
|
218
218
|
try:
|
|
219
219
|
self.pool = self._create_connection_pool()
|
|
220
|
-
logger.
|
|
220
|
+
logger.debug('成功重新建立数据库连接')
|
|
221
221
|
except Exception as reconnect_error:
|
|
222
222
|
logger.error('重连失败', {'error': str(reconnect_error)})
|
|
223
223
|
else:
|
|
@@ -251,7 +251,7 @@ class MySQLUploader:
|
|
|
251
251
|
try:
|
|
252
252
|
self.pool = self._create_connection_pool()
|
|
253
253
|
conn = self.pool.connection()
|
|
254
|
-
logger.
|
|
254
|
+
logger.debug('重建连接池后获取连接成功')
|
|
255
255
|
return conn
|
|
256
256
|
except Exception as e2:
|
|
257
257
|
logger.error('重建连接池后依然获取连接失败', {'error': str(e2)})
|
|
@@ -296,7 +296,7 @@ class MySQLUploader:
|
|
|
296
296
|
with conn.cursor() as cursor:
|
|
297
297
|
cursor.execute(sql)
|
|
298
298
|
conn.commit()
|
|
299
|
-
logger.
|
|
299
|
+
logger.debug('数据库已创建', {'库': db_name})
|
|
300
300
|
except Exception as e:
|
|
301
301
|
logger.error('无法创建数据库', {'库': db_name, '错误': str(e)})
|
|
302
302
|
if conn is not None:
|
|
@@ -602,7 +602,7 @@ class MySQLUploader:
|
|
|
602
602
|
with conn.cursor() as cursor:
|
|
603
603
|
cursor.execute(sql)
|
|
604
604
|
conn.commit()
|
|
605
|
-
logger.
|
|
605
|
+
logger.debug('数据表及索引已创建', {'库': db_name, '表': table_name, '索引': indexes, '唯一约束': unique_keys})
|
|
606
606
|
except Exception as e:
|
|
607
607
|
logger.error('建表失败', {'库': db_name, '表': table_name, '错误': str(e), '异常类型': type(e).__name__})
|
|
608
608
|
if conn is not None:
|
|
@@ -909,7 +909,7 @@ class MySQLUploader:
|
|
|
909
909
|
return
|
|
910
910
|
cursor.execute(sql_create)
|
|
911
911
|
conn.commit()
|
|
912
|
-
logger.
|
|
912
|
+
logger.debug('已为列创建索引', {'库': db_name, '表': table_name, '列': column})
|
|
913
913
|
except Exception as e:
|
|
914
914
|
logger.error('创建索引失败', {'库': db_name, '表': table_name, '列': column, '错误': str(e)})
|
|
915
915
|
raise
|
|
@@ -953,7 +953,7 @@ class MySQLUploader:
|
|
|
953
953
|
with conn.cursor() as cursor:
|
|
954
954
|
cursor.execute(sql)
|
|
955
955
|
conn.commit()
|
|
956
|
-
logger.
|
|
956
|
+
logger.debug('添加唯一约束列成功', {'库': db_name, '表': table_name, '列': unique_cols})
|
|
957
957
|
except Exception as e:
|
|
958
958
|
logger.warning('唯一约束列添加失败', {'库': db_name, '表': table_name, '列': unique_cols, '错误': str(e)})
|
|
959
959
|
|
|
@@ -1343,7 +1343,7 @@ class MySQLUploader:
|
|
|
1343
1343
|
validated_indexes = self._validate_indexes_format(indexes, db_name, table_name)
|
|
1344
1344
|
validated_unique_keys = self._validate_unique_keys_format(unique_keys, db_name, table_name)
|
|
1345
1345
|
|
|
1346
|
-
logger.
|
|
1346
|
+
logger.debug("开始上传", {
|
|
1347
1347
|
'库': db_name,
|
|
1348
1348
|
'表': table_name,
|
|
1349
1349
|
'批次': batch_id,
|
|
@@ -1548,7 +1548,7 @@ class MySQLUploader:
|
|
|
1548
1548
|
batch_id, transaction_mode,
|
|
1549
1549
|
update_on_duplicate
|
|
1550
1550
|
)
|
|
1551
|
-
logger.
|
|
1551
|
+
logger.debug('插入完成', {
|
|
1552
1552
|
'库': db_name,
|
|
1553
1553
|
'表': table_name,
|
|
1554
1554
|
'总计': len(data),
|
mdbq-4.1.1/mdbq/__version__.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
VERSION = '4.1.1'
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|