mdbq 1.9.2__tar.gz → 1.9.4__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.
Files changed (46) hide show
  1. {mdbq-1.9.2 → mdbq-1.9.4}/PKG-INFO +1 -1
  2. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/aggregation/aggregation.py +10 -0
  3. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/clean/data_clean.py +12 -0
  4. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/mysql/mysql.py +12 -0
  5. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq.egg-info/PKG-INFO +1 -1
  6. {mdbq-1.9.2 → mdbq-1.9.4}/setup.py +1 -1
  7. {mdbq-1.9.2 → mdbq-1.9.4}/README.txt +0 -0
  8. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/__init__.py +0 -0
  9. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/__version__.py +0 -0
  10. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/aggregation/__init__.py +0 -0
  11. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/aggregation/df_types.py +0 -0
  12. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/aggregation/mysql_types.py +0 -0
  13. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/aggregation/optimize_data.py +0 -0
  14. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/aggregation/query_data.py +0 -0
  15. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/bdup/__init__.py +0 -0
  16. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/bdup/bdup.py +0 -0
  17. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/clean/__init__.py +0 -0
  18. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/company/__init__.py +0 -0
  19. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/company/copysh.py +0 -0
  20. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/config/__init__.py +0 -0
  21. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/config/get_myconf.py +0 -0
  22. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/config/products.py +0 -0
  23. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/config/set_support.py +0 -0
  24. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/config/update_conf.py +0 -0
  25. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/dataframe/__init__.py +0 -0
  26. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/dataframe/converter.py +0 -0
  27. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/log/__init__.py +0 -0
  28. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/log/mylogger.py +0 -0
  29. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/mongo/__init__.py +0 -0
  30. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/mongo/mongo.py +0 -0
  31. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/mysql/__init__.py +0 -0
  32. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/mysql/s_query.py +0 -0
  33. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/mysql/year_month_day.py +0 -0
  34. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/other/__init__.py +0 -0
  35. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/other/porxy.py +0 -0
  36. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/other/pov_city.py +0 -0
  37. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/other/sku_picture.py +0 -0
  38. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/other/ua_sj.py +0 -0
  39. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/pbix/__init__.py +0 -0
  40. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/pbix/pbix_refresh.py +0 -0
  41. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/pbix/refresh_all.py +0 -0
  42. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq/spider/__init__.py +0 -0
  43. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq.egg-info/SOURCES.txt +0 -0
  44. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq.egg-info/dependency_links.txt +0 -0
  45. {mdbq-1.9.2 → mdbq-1.9.4}/mdbq.egg-info/top_level.txt +0 -0
  46. {mdbq-1.9.2 → mdbq-1.9.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mdbq
3
- Version: 1.9.2
3
+ Version: 1.9.4
4
4
  Home-page: https://pypi.org/project/mdbsql
5
5
  Author: xigua,
6
6
  Author-email: 2587125111@qq.com
@@ -474,10 +474,20 @@ class DatabaseUpdate:
474
474
  elif name.endswith('.xlsx') and '搜索分析-排名定位-商品词下排名' in name:
475
475
  # 京东商品词下排名
476
476
  try:
477
+ pattern = re.findall(r'(\d{4}-\d{2}-\d{2})-(\d{4}-\d{2}-\d{2})', name)
478
+ if not pattern:
479
+ continue
480
+ if pattern[0][0] == pattern[0][1]:
481
+ print(f'{name}: 检测到数据周期异常,仅支持7天数据')
482
+ continue
477
483
  df = pd.read_excel(os.path.join(root, name), header=0, engine='openpyxl')
478
484
  if len(df) == 0:
479
485
  print(f'{name} 报表数据为空')
480
486
  continue
487
+ if len(df.columns.tolist()) < 20:
488
+ print(f'{name}: 报表可能缺失诊断数据')
489
+ os.remove(os.path.join(root, name))
490
+ continue
481
491
  df.rename(columns={'商品的ID': 'skuid'}, inplace=True)
482
492
  for col in ['词人气', '搜索点击率']:
483
493
  if col in df.columns.tolist():
@@ -827,6 +827,14 @@ class DataClean:
827
827
  os.remove(os.path.join(root, name))
828
828
  elif name.endswith('.xlsx') and '搜索分析-排名定位-商品词下排名' in name:
829
829
  # 京东商品词下排名
830
+ pattern = re.findall(r'(\d{4}-\d{2}-\d{2})-(\d{4}-\d{2}-\d{2})', name)
831
+ if not pattern:
832
+ os.remove(os.path.join(root, name))
833
+ continue
834
+ if pattern[0][0] == pattern[0][1]:
835
+ print(f'{name}: 检测到数据周期异常,仅支持7天数据')
836
+ os.remove(os.path.join(root, name))
837
+ continue
830
838
  new_name = os.path.splitext(name)[0] + '.csv'
831
839
  # print(name)
832
840
  df = pd.read_excel(os.path.join(root, name), header=0, engine='openpyxl')
@@ -834,6 +842,10 @@ class DataClean:
834
842
  print(f'{name} 报表数据为空')
835
843
  os.remove(os.path.join(root, name))
836
844
  continue
845
+ if len(df.columns.tolist()) < 20:
846
+ print(f'{name}: 报表可能缺失诊断数据')
847
+ os.remove(os.path.join(root, name))
848
+ continue
837
849
  df.rename(columns={'商品的ID': 'skuid'}, inplace=True)
838
850
  df['skuid'] = df['skuid'].apply(lambda x: f'="{x}"' if x and '=' not in str(x) else x)
839
851
  self.save_to_csv(df, root, new_name)
@@ -57,6 +57,18 @@ class MysqlUpload:
57
57
  }
58
58
  self.filename = None
59
59
 
60
+ @staticmethod
61
+ def try_except(func): # 在类内部定义一个异常处理方法
62
+ @wraps(func)
63
+ def wrapper(*args, **kwargs):
64
+ try:
65
+ return func(*args, **kwargs)
66
+ except Exception as e:
67
+ print(f'{func.__name__}, {e}') # 将异常信息返回
68
+
69
+ return wrapper
70
+
71
+ @try_except
60
72
  def df_to_mysql(self, df, table_name, db_name='远程数据源', icm_update=[], service_database={'home_lx': 'mysql'}, move_insert=False, df_sql=False, drop_duplicates=False, filename=None, count=None, json_path=None):
61
73
  """
62
74
  将 df 写入数据库
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mdbq
3
- Version: 1.9.2
3
+ Version: 1.9.4
4
4
  Home-page: https://pypi.org/project/mdbsql
5
5
  Author: xigua,
6
6
  Author-email: 2587125111@qq.com
@@ -3,7 +3,7 @@
3
3
  from setuptools import setup, find_packages
4
4
 
5
5
  setup(name='mdbq',
6
- version='1.9.2',
6
+ version='1.9.4',
7
7
  author='xigua, ',
8
8
  author_email="2587125111@qq.com",
9
9
  url='https://pypi.org/project/mdbsql',
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