mdbq 4.1.0__py3-none-any.whl → 4.1.2__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.

Potentially problematic release.


This version of mdbq might be problematic. Click here for more details.

mdbq/__version__.py CHANGED
@@ -1 +1 @@
1
- VERSION = '4.1.0'
1
+ VERSION = '4.1.2'
mdbq/auth/auth_backend.py CHANGED
@@ -82,12 +82,6 @@ ROLE_PERMISSIONS = {
82
82
  "read", "write", "create", "update", "database",
83
83
  "file_upload", "file_download", "api_read"
84
84
  ],
85
-
86
- "vi_user": [
87
- # 降级的用户权限
88
- "read", "database",
89
- "file_upload", "file_download", "api_read"
90
- ],
91
85
 
92
86
  "viewer": [
93
87
  # 只读权限
@@ -224,7 +218,7 @@ class StandaloneAuthManager:
224
218
  password_hash VARCHAR(128) NOT NULL,
225
219
  password_plain TEXT NOT NULL,
226
220
  salt VARCHAR(64) NOT NULL,
227
- role ENUM('super_admin', 'admin', 'manager', 'editor', 'user', 'vi_user', 'viewer', 'api_user', 'auditor') NOT NULL DEFAULT 'user',
221
+ role ENUM('super_admin', 'admin', 'manager', 'editor', 'user', 'viewer', 'api_user', 'auditor') NOT NULL DEFAULT 'user',
228
222
  permissions JSON DEFAULT (JSON_ARRAY()),
229
223
  is_active TINYINT(1) NOT NULL DEFAULT 1,
230
224
  created_at TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
@@ -477,7 +471,6 @@ class StandaloneAuthManager:
477
471
  return {'success': False, 'message': '密码至少需要6个字符'}
478
472
 
479
473
  # 邮箱格式验证
480
- import re
481
474
  email_pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
482
475
  if not re.match(email_pattern, email):
483
476
  return {'success': False, 'message': '请输入有效的邮箱地址'}
@@ -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.info('去重日期范围', {'开始': self._dedup_start_date, '结束': self._dedup_end_date})
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.info('没有重复数据', {"库": database, "表": table, "数据量": total_count, "数据日期": date_val})
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.info('没有重复数据', {"库": database, "表": table, "数据量": total_count})
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.info('单表开始', {
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.info('无可处理日期', {"库": database, "表": table})
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.info('单表完成', {"库": database, "表": table, "结果[重复, 删除]": (total_dup, total_del), '日期范围': f"{start_date} - {end_date}", "唯一列": columns})
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.info('库统计', {"库": database, "表数量": len(target_tables), "表列表": target_tables})
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.info("数据库连接池已关闭")
1076
+ logger.debug("数据库连接池已关闭")
1077
1077
  else:
1078
- logger.info('连接池已关闭或不存在')
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.info('开始id重排', {"库": database, "表": table, "重排列": id_column, "试运行": dry_run, "DDL警告": "MySQL DDL操作不可回滚,建议提前备份!"})
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文件', '日志', '视频数据', '云电影', 'api_monitor_logs', 'redis统计', 'standalone_auth', 'website_data'],
1373
+ exclude_databases=['cookie文件', '日志', '视频数据', '云电影'],
1374
1374
  # exclude_tables={
1375
1375
  # '推广数据2': [
1376
1376
  # '地域报表_城市_2025_04',
mdbq/mysql/uploader.py CHANGED
@@ -199,7 +199,7 @@ class MySQLUploader:
199
199
  try:
200
200
  result = func(self, *args, **kwargs)
201
201
  if attempt > 0:
202
- logger.info('操作成功(重试后)', {'operation': operation, 'attempts': attempt + 1})
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.info('成功重新建立数据库连接')
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.info('重建连接池后获取连接成功')
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.info('数据库已创建', {'库': db_name})
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.info('数据表及索引已创建', {'库': db_name, '表': table_name, '索引': indexes, '唯一约束': unique_keys})
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.info('已为列创建索引', {'库': db_name, '表': table_name, '列': column})
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.info('添加唯一约束列成功', {'库': db_name, '表': table_name, '列': unique_cols})
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.info("开始上传", {
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.info('插入完成', {
1551
+ logger.debug('插入完成', {
1552
1552
  '库': db_name,
1553
1553
  '表': table_name,
1554
1554
  '总计': len(data),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mdbq
3
- Version: 4.1.0
3
+ Version: 4.1.2
4
4
  Home-page: https://pypi.org/project/mdbq
5
5
  Author: xigua,
6
6
  Author-email: 2587125111@qq.com
@@ -1,7 +1,7 @@
1
1
  mdbq/__init__.py,sha256=Il5Q9ATdX8yXqVxtP_nYqUhExzxPC_qk_WXQ_4h0exg,16
2
- mdbq/__version__.py,sha256=UqHfTBXjnn3SF52tR6mC_eYSYdxboYUuHdD7FYSn0kc,17
2
+ mdbq/__version__.py,sha256=t0Fz3FVzbu8dTQm35pWtvOg5K2EJnfXWvbSU90YalwU,17
3
3
  mdbq/auth/__init__.py,sha256=pnPMAt63sh1B6kEvmutUuro46zVf2v2YDAG7q-jV_To,24
4
- mdbq/auth/auth_backend.py,sha256=07OTh0e1LDO_Ws-an1EvzIve8mvfBNCKJn_xjrOD-rw,99920
4
+ mdbq/auth/auth_backend.py,sha256=u8qwMNjAdDliaaFzfulVqQIoFrIJhe980OdYwTIVKJg,99750
5
5
  mdbq/auth/crypto.py,sha256=fcZRFCnrKVVdWDUx_zds51ynFYwS9DBvJOrRQVldrfM,15931
6
6
  mdbq/auth/rate_limiter.py,sha256=1m_Paxp8pDNpmyoFGRpFMVOJpbmeIvfVcfiQ2oH72qM,32850
7
7
  mdbq/js/__init__.py,sha256=hpMi3_ZKwIWkzc0LnKL-SY9AS-7PYFHq0izYTgEvxjc,30
@@ -11,11 +11,11 @@ mdbq/log/mylogger.py,sha256=DyBftCMNLe1pTTXsa830pUtDISJxpJHFIradYtE3lFA,26418
11
11
  mdbq/myconf/__init__.py,sha256=jso1oHcy6cJEfa7udS_9uO5X6kZLoPBF8l3wCYmr5dM,18
12
12
  mdbq/myconf/myconf.py,sha256=rHvQCnQRKhQ49AZBke-Z4v28hyOLmHt4MylIuB0H6yA,33516
13
13
  mdbq/mysql/__init__.py,sha256=A_DPJyAoEvTSFojiI2e94zP0FKtCkkwKP1kYUCSyQzo,11
14
- mdbq/mysql/deduplicator.py,sha256=Sfv5vgMk703luYeNwm-p5kOiKJ3fa6bm1ltc2Q6pOv4,73144
14
+ mdbq/mysql/deduplicator.py,sha256=2fugLyKs_xkvYvoG0C0hRYbJ_w8-4oa1FJ_vavoD7Qo,73084
15
15
  mdbq/mysql/mysql.py,sha256=pDg771xBugCMSTWeskIFTi3pFLgaqgyG3smzf-86Wn8,56772
16
16
  mdbq/mysql/s_query.py,sha256=nwhyqbxq-V0sGUJbdjiUDEwjpDxiKrzG0PjV6wkrWU4,50474
17
17
  mdbq/mysql/unique_.py,sha256=MaztT-WIyEQUs-OOYY4pFulgHVcXR1BfCy3QUz0XM_U,21127
18
- mdbq/mysql/uploader.py,sha256=xodmN3f5pT1T2yJu01ckgYb_THE__rm81kgNJfqtinc,111530
18
+ mdbq/mysql/uploader.py,sha256=FG_4btNwTjbCqZFeIigCfar7r-OOA7VkyuJsOOC9WLw,111539
19
19
  mdbq/other/__init__.py,sha256=jso1oHcy6cJEfa7udS_9uO5X6kZLoPBF8l3wCYmr5dM,18
20
20
  mdbq/other/download_sku_picture.py,sha256=X66sVdvVgzoNzmgVJyPtd7bjEvctEKtLPblEPF65EWc,46940
21
21
  mdbq/other/error_handler.py,sha256=4p5haAXSY-P78stp4Xwo_MwAngWYqyKj5ogWIuYXMeY,12631
@@ -35,7 +35,7 @@ mdbq/route/routes.py,sha256=QVGfTvDgu0CpcKCvk1ra74H8uojgqTLUav1fnVAqLEA,29433
35
35
  mdbq/selenium/__init__.py,sha256=AKzeEceqZyvqn2dEDoJSzDQnbuENkJSHAlbHAD0u0ZI,10
36
36
  mdbq/selenium/get_driver.py,sha256=1NTlVUE6QsyjTrVVVqTO2LOnYf578ccFWlWnvIXGtic,20903
37
37
  mdbq/spider/__init__.py,sha256=RBMFXGy_jd1HXZhngB2T2XTvJqki8P_Fr-pBcwijnew,18
38
- mdbq-4.1.0.dist-info/METADATA,sha256=pgGi7sn574SavY6o8zpGQnL2cceJ2KZsrm2J_7WR4WQ,363
39
- mdbq-4.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
40
- mdbq-4.1.0.dist-info/top_level.txt,sha256=2FQ-uLnCSB-OwFiWntzmwosW3X2Xqsg0ewh1axsaylA,5
41
- mdbq-4.1.0.dist-info/RECORD,,
38
+ mdbq-4.1.2.dist-info/METADATA,sha256=PsddxgvUrLRPSZGLVd4b64UA19gU-LjiHkK2FV1_OVM,363
39
+ mdbq-4.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
40
+ mdbq-4.1.2.dist-info/top_level.txt,sha256=2FQ-uLnCSB-OwFiWntzmwosW3X2Xqsg0ewh1axsaylA,5
41
+ mdbq-4.1.2.dist-info/RECORD,,
File without changes