mdbq 1.1.4__tar.gz → 1.1.6__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.1.4 → mdbq-1.1.6}/PKG-INFO +1 -1
  2. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/aggregation/aggregation.py +31 -12
  3. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq.egg-info/PKG-INFO +1 -1
  4. {mdbq-1.1.4 → mdbq-1.1.6}/setup.py +1 -1
  5. {mdbq-1.1.4 → mdbq-1.1.6}/README.txt +0 -0
  6. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/__init__.py +0 -0
  7. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/__version__.py +0 -0
  8. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/aggregation/__init__.py +0 -0
  9. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/aggregation/df_types.py +0 -0
  10. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/aggregation/mysql_types.py +0 -0
  11. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/aggregation/optimize_data.py +0 -0
  12. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/aggregation/query_data.py +0 -0
  13. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/bdup/__init__.py +0 -0
  14. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/bdup/bdup.py +0 -0
  15. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/clean/__init__.py +0 -0
  16. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/clean/data_clean.py +0 -0
  17. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/company/__init__.py +0 -0
  18. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/company/copysh.py +0 -0
  19. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/config/__init__.py +0 -0
  20. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/config/get_myconf.py +0 -0
  21. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/config/products.py +0 -0
  22. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/config/set_support.py +0 -0
  23. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/config/update_conf.py +0 -0
  24. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/dataframe/__init__.py +0 -0
  25. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/dataframe/converter.py +0 -0
  26. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/log/__init__.py +0 -0
  27. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/log/mylogger.py +0 -0
  28. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/mongo/__init__.py +0 -0
  29. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/mongo/mongo.py +0 -0
  30. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/mysql/__init__.py +0 -0
  31. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/mysql/data_types_/345/215/263/345/260/206/345/210/240/351/231/244.py" +0 -0
  32. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/mysql/mysql.py +0 -0
  33. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/mysql/s_query.py +0 -0
  34. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/mysql/year_month_day.py +0 -0
  35. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/other/__init__.py +0 -0
  36. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/other/porxy.py +0 -0
  37. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/other/pov_city.py +0 -0
  38. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/other/ua_sj.py +0 -0
  39. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/pbix/__init__.py +0 -0
  40. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/pbix/pbix_refresh.py +0 -0
  41. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/pbix/refresh_all.py +0 -0
  42. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq/spider/__init__.py +0 -0
  43. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq.egg-info/SOURCES.txt +0 -0
  44. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq.egg-info/dependency_links.txt +0 -0
  45. {mdbq-1.1.4 → mdbq-1.1.6}/mdbq.egg-info/top_level.txt +0 -0
  46. {mdbq-1.1.4 → mdbq-1.1.6}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mdbq
3
- Version: 1.1.4
3
+ Version: 1.1.6
4
4
  Home-page: https://pypi.org/project/mdbsql
5
5
  Author: xigua,
6
6
  Author-email: 2587125111@qq.com
@@ -849,8 +849,11 @@ class DatabaseUpdate:
849
849
  return df
850
850
 
851
851
 
852
- def upload(path, db_name, collection_name, one_file=False):
852
+ def upload(path, db_name, collection_name):
853
853
  """ 上传一个文件夹到数据库 """
854
+ if not os.path.isdir(path):
855
+ print(f'{os.path.splitext(os.path.basename(__file__))[0]}.upload: 函数只接受文件夹路径,不是一个文件夹: {path}')
856
+ return
854
857
  username, password, host, port = get_myconf.select_config_values(
855
858
  target_service='home_lx',
856
859
  database='mongodb',
@@ -888,7 +891,7 @@ def upload(path, db_name, collection_name, one_file=False):
888
891
  db_name=db_name,
889
892
  collection_name=collection_name,
890
893
  )
891
- # print(dtypes)
894
+
892
895
  count = 0
893
896
  for root, dirs, files in os.walk(path, topdown=False):
894
897
  for name in files:
@@ -920,12 +923,18 @@ def upload(path, db_name, collection_name, one_file=False):
920
923
  except Exception as e:
921
924
  print(name, e)
922
925
  i += 1
923
- if one_file: # 给 file_dir 函数调用
924
- break # 每个文件夹只上传一个文件
925
926
  if d.client:
926
927
  d.client.close() # 必须手动关闭数据库连接
927
928
 
928
929
 
930
+ def one_file_to_mysql(file, db_name, table_name, target_service, database):
931
+ username, password, host, port = get_myconf.select_config_values(target_service=target_service, database=database)
932
+ filename = os.path.basename(file)
933
+ df = pd.read_csv(file, encoding='utf-8_sig', header=0, na_filter=False, float_precision='high')
934
+ m = mysql.MysqlUpload(username=username, password=password, host=host, port=port)
935
+ m.df_to_mysql(df=df, db_name=db_name, table_name=table_name, filename=filename)
936
+
937
+
929
938
  def file_dir():
930
939
  """
931
940
  按照文件记录对照表
@@ -941,16 +950,26 @@ def file_dir():
941
950
  for data in datas:
942
951
  # print(data)
943
952
  if data['入库进度'] == 0:
944
- sub_path, db_name, collection_name = data['子文件夹'], data['数据库名'], data['数据表']
945
- # print(os.path.join(path, sub_path), db_name, collection_name)
946
- upload(
947
- path=os.path.join(path, sub_path),
948
- db_name=db_name,
949
- collection_name=collection_name,
950
- one_file=True
951
- )
953
+ sub_path, db_name, table_name = data['子文件夹'], data['数据库名'], data['数据表']
954
+ # print(os.path.join(path, sub_path), db_name, table_name)
955
+ # 从每个文件夹中取出一个文件
956
+ real_path_list = []
957
+ for root, dirs, files in os.walk(os.path.join(path, sub_path), topdown=False):
958
+ for name in files:
959
+ if name.endswith('.csv') and 'baidu' not in name and '~' not in name:
960
+ real_path_list.append(os.path.join(root, name))
961
+ break
962
+ for real_path in real_path_list:
963
+ one_file_to_mysql(
964
+ file=real_path,
965
+ db_name=db_name,
966
+ table_name=table_name,
967
+ target_service='home_lx',
968
+ database='mysql'
969
+ )
952
970
  data.update({'入库进度': 1}) # 更新进度
953
971
  df = pd.DataFrame.from_dict(datas, orient='columns')
972
+ # print(df)
954
973
  df.to_csv(os.path.join(path, filename), encoding='utf-8_sig', index=False, header=True)
955
974
 
956
975
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mdbq
3
- Version: 1.1.4
3
+ Version: 1.1.6
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.1.4',
6
+ version='1.1.6',
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
File without changes