mdbq 0.3.4__py3-none-any.whl → 0.3.6__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/company/copysh.py CHANGED
@@ -339,8 +339,8 @@ def main():
339
339
  dp.upload_df(service_databases=[{'company': 'mysql'}])
340
340
 
341
341
  # 此操作用于修改 .copysh_conf 文件,将 ch_record 改为 false (更新完成)
342
- w = update_conf.UpdateConf(filename='.copysh_conf')
343
- w.update_config(option='ch_record', new_value='False')
342
+ w = update_conf.UpdateConf()
343
+ w.update_config(filename='.copysh_conf', option='ch_record', new_value='False')
344
344
  time.sleep(60)
345
345
  op_data(days=3650) # 数据清理和聚合
346
346
 
@@ -4,6 +4,10 @@ import getpass
4
4
  import configparser
5
5
  import os
6
6
  from urllib import parse
7
+ """
8
+ 文件被 copysh.py / all-datas.py 调用, update_config 函数
9
+ 更新完成后修改 conf 中值为 True
10
+ """
7
11
 
8
12
 
9
13
  class UpdateConf:
@@ -11,31 +15,56 @@ class UpdateConf:
11
15
  读取配置文件信息
12
16
  理论上,在本程序的根目录需要有一个文件夹 support/.myconf 配置文件放在其下
13
17
  """
14
- def __init__(self, filename):
18
+ def __init__(self):
15
19
  if platform.system() == 'Darwin':
16
- path = os.path.join('/Users', getpass.getuser(), '数据中心/自动0备份/py/数据更新/support')
20
+ self.path = os.path.join('/Users', getpass.getuser(), '数据中心/自动0备份/py/数据更新/support')
17
21
  elif platform.system() == 'Windows':
18
- path = os.path.join('C:\\同步空间\\BaiduSyncdisk\\自动0备份\\py\\数据更新\\support')
22
+ self.path = os.path.join('C:\\同步空间\\BaiduSyncdisk\\自动0备份\\py\\数据更新\\support')
19
23
  else:
20
- path = os.path.join('/Users', getpass.getuser(), 'support')
21
- self.path = path
22
- self.filename = filename
23
- self.conf_file = os.path.join(self.path, self.filename)
24
+ self.path = os.path.join('/Users', getpass.getuser(), 'support')
25
+ self.section = 'database' # 默认 文件头标记
26
+ self.filename = None
27
+ self.conf_file = None
24
28
  self.config = None
25
- self.section = 'database'
26
29
 
30
+ def read_txt(self, filename, option=None):
31
+ self.filename = filename
32
+ self.conf_file = os.path.join(self.path, self.filename)
33
+ if not os.path.exists(self.conf_file):
34
+ print(f'缺少配置文件: {self.conf_file}')
35
+ return
36
+ with open(self.conf_file, 'r', encoding='utf-8') as f:
37
+ content = f.readlines()
38
+ content = [item.strip() for item in content if not item.strip().startswith('#') and not item.strip().startswith('[')]
39
+ pbix_list = [item for item in content if item]
40
+ return pbix_list # ['推广数据.pbix', '市场数据新.pbix']
27
41
 
28
- def read_conf(self, option, value):
42
+ def read_conf(self, filename, option=None):
43
+ self.filename = filename
44
+ self.conf_file = os.path.join(self.path, self.filename)
29
45
  if not os.path.exists(self.conf_file):
30
- print(f'缺少配置文件')
46
+ print(f'缺少配置文件: {self.conf_file}')
31
47
  return
32
48
  self.config = configparser.ConfigParser()
33
49
  self.config.read(self.conf_file, 'UTF-8')
34
- res = self.config.get('database', option)
35
- print(res)
50
+ if not option:
51
+ results = []
52
+ for option in self.config.options(self.section):
53
+ results.append({option: self.config.get(self.section, option)})
54
+ return results
55
+ else:
56
+ if option not in self.config.options(self.section):
57
+ print(f'不存在的配置项: {option},文件: {self.conf_file}')
58
+ else:
59
+ return self.config.get(self.section, option)
36
60
 
37
- def update_config(self, option, new_value):
38
- """ 更新配置文件 """
61
+ def update_config(self, filename, option, new_value):
62
+ """
63
+ 更新配置文件
64
+ copysh.py / all-datas.py 调用
65
+ """
66
+ self.filename = filename
67
+ self.conf_file = os.path.join(self.path, self.filename)
39
68
  with open(self.conf_file, 'r', encoding='utf-8') as file:
40
69
  lines = file.readlines()
41
70
  config = configparser.ConfigParser(allow_no_value=True) # 读取配置(不包括注释和空白行)
@@ -67,7 +96,12 @@ class UpdateConf:
67
96
  file.write(f"\n[{self.section}]\n{option} = {new_value}\n")
68
97
 
69
98
 
70
- if __name__ == '__main__':
71
- # w = UpdateConf(filename='.copysh_conf')
72
- # w.update_config(option='ch_record', new_value='false')
99
+ def main():
73
100
  pass
101
+
102
+
103
+ if __name__ == '__main__':
104
+ w = UpdateConf()
105
+ # w.update_config(filename='.copysh_conf', option='ch_record', new_value='false')
106
+ res = w.read_txt(filename='tb_list.txt')
107
+ print(res)
mdbq/mysql/data_types.py CHANGED
@@ -69,7 +69,7 @@ class DataTypes:
69
69
  """ 更新 dataframe 的 dtypes 信息到 json 文件 """
70
70
  if not os.path.exists(path):
71
71
  os.makedirs(path)
72
- json_file = os.path.join(path, 'df_dtypes.json')
72
+ json_file = os.path.join(path, 'mysql_types.json')
73
73
  if os.path.isfile(json_file):
74
74
  self.json_before(json_file=json_file) # 更新本地json信息到 self.datas
75
75
 
@@ -143,7 +143,7 @@ class DataTypes:
143
143
  if os.path.isfile(path):
144
144
  self.json_before(json_file=path) # 更新本地json信息到 self.datas
145
145
  elif os.path.isdir(path):
146
- json_file = os.path.join(path, 'df_dtypes.json')
146
+ json_file = os.path.join(path, 'mysql_types.json')
147
147
  if os.path.isfile(json_file):
148
148
  self.json_before(json_file=json_file)
149
149
  else:
mdbq/mysql/mysql.py CHANGED
@@ -196,7 +196,7 @@ class MysqlUpload:
196
196
  path = os.path.join('C:\\同步空间\\BaiduSyncdisk\\自动0备份\\py\\数据更新\\support')
197
197
  else:
198
198
  path = os.path.join('/Users', getpass.getuser(), 'support')
199
- # json_file = os.path.join(path, 'df_dtypes.json')
199
+ # json_file = os.path.join(path, 'mysql_types.json')
200
200
  # if os.path.isfile(json_file):
201
201
  d = data_types.DataTypes()
202
202
  # 从本地文件中读取 dtype 信息
mdbq/pbix/refresh_all.py CHANGED
@@ -27,7 +27,7 @@ class RefreshAll:
27
27
  return
28
28
  with open(self.pbix_path, 'r', encoding='utf-8') as f:
29
29
  content = f.readlines()
30
- content = [item.strip() for item in content if not item.strip().startswith('#')]
30
+ content = [item.strip() for item in content if not item.strip().startswith('#') and not item.strip().startswith('[')]
31
31
  pbix_list = [item for item in content if item]
32
32
 
33
33
  if not pbix_list:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mdbq
3
- Version: 0.3.4
3
+ Version: 0.3.6
4
4
  Home-page: https://pypi.org/project/mdbsql
5
5
  Author: xigua,
6
6
  Author-email: 2587125111@qq.com
@@ -9,11 +9,11 @@ mdbq/bdup/bdup.py,sha256=LAV0TgnQpc-LB-YuJthxb0U42_VkPidzQzAagan46lU,4234
9
9
  mdbq/clean/__init__.py,sha256=A1d6x3L27j4NtLgiFV5TANwEkLuaDfPHDQNrPBbNWtU,41
10
10
  mdbq/clean/data_clean.py,sha256=33OmeQFl9AW21P5EOay52W_S8DF96H5oHwCg4fSuBxA,85359
11
11
  mdbq/company/__init__.py,sha256=qz8F_GsP_pMB5PblgJAUAMjasuZbOEp3qQOCB39E8f0,21
12
- mdbq/company/copysh.py,sha256=ANpwPLtw1PLH9U2EdzQAavA83QHPmAcSbtrbot4I1MQ,17024
12
+ mdbq/company/copysh.py,sha256=kJCvFym4eu8r8kesKlAgO_T-popl3_WdvN6pasihph8,17026
13
13
  mdbq/config/__init__.py,sha256=jso1oHcy6cJEfa7udS_9uO5X6kZLoPBF8l3wCYmr5dM,18
14
14
  mdbq/config/get_myconf.py,sha256=9v3xebfcS1tptxpvk3_tGxfXjAehGVCveYe4iRUzLQQ,6372
15
15
  mdbq/config/products.py,sha256=tFqSfFSXyZXcof0gAeHq0Ftn4F5i9ucoMyIqZ1H_D2Q,4260
16
- mdbq/config/update_conf.py,sha256=YjGjjRchu5BcrmLJkoLjHEF2TbGOmsgCWX4LroXOYWQ,3455
16
+ mdbq/config/update_conf.py,sha256=8uOiV7CY5HCzg2PVjuKHNqYJNwJR0M7B-a7egta3wWw,4952
17
17
  mdbq/dataframe/__init__.py,sha256=2HtCN8AdRj53teXDqzysC1h8aPL-mMFy561ESmhehGQ,22
18
18
  mdbq/dataframe/converter.py,sha256=h_BDc6oNmMCVFOUzZJq4nXNGDyJFJyycpWqlyrv7U04,3089
19
19
  mdbq/log/__init__.py,sha256=Mpbrav0s0ifLL7lVDAuePEi1hJKiSHhxcv1byBKDl5E,15
@@ -21,8 +21,8 @@ mdbq/log/mylogger.py,sha256=oaT7Bp-Hb9jZt52seP3ISUuxVcI19s4UiqTeouScBO0,3258
21
21
  mdbq/mongo/__init__.py,sha256=SILt7xMtQIQl_m-ik9WLtJSXIVf424iYgCfE_tnQFbw,13
22
22
  mdbq/mongo/mongo.py,sha256=q0B4wXDSTtXg_vMN7MPh6zdxl6tT68tM74LmdVNQQek,31892
23
23
  mdbq/mysql/__init__.py,sha256=A_DPJyAoEvTSFojiI2e94zP0FKtCkkwKP1kYUCSyQzo,11
24
- mdbq/mysql/data_types.py,sha256=JhKhSoj1FihCl_8yfjVqWOlISJ0hx6tBQR0qE7n-Z3U,11153
25
- mdbq/mysql/mysql.py,sha256=42IJOAWiSoic4m_u3_875F2IzKHIW-2dNWx7OYZ0Ub4,33901
24
+ mdbq/mysql/data_types.py,sha256=Heb_bccgi2RL8YEwIxg7jyVdjdWuBN4n2J_5Uz_S-GQ,11157
25
+ mdbq/mysql/mysql.py,sha256=QghST_eVHRn6HmDnBr6J5LFiGkp8qVHvqdYpFifEoqw,33903
26
26
  mdbq/mysql/s_query.py,sha256=6-8O9MHhi3-7n3isJ7t2kTCYL2mSBC_HrxSQmXM5UtI,7901
27
27
  mdbq/mysql/year_month_day.py,sha256=VgewoE2pJxK7ErjfviL_SMTN77ki8GVbTUcao3vFUCE,1523
28
28
  mdbq/other/__init__.py,sha256=jso1oHcy6cJEfa7udS_9uO5X6kZLoPBF8l3wCYmr5dM,18
@@ -31,9 +31,9 @@ mdbq/other/pov_city.py,sha256=AEOmCOzOwyjHi9LLZWPKi6DUuSC-_M163664I52u9qw,21050
31
31
  mdbq/other/ua_sj.py,sha256=JuVYzc_5QZ9s_oQSrTHVKkQv4S_7-CWx4oIKOARn_9U,22178
32
32
  mdbq/pbix/__init__.py,sha256=Trtfaynu9RjoTyLLYBN2xdRxTvm_zhCniUkVTAYwcjo,24
33
33
  mdbq/pbix/pbix_refresh.py,sha256=JUjKW3bNEyoMVfVfo77UhguvS5AWkixvVhDbw4_MHco,2396
34
- mdbq/pbix/refresh_all.py,sha256=wulHs4rivf4Mi0Pii2QR5Nk9-TBcvSwnCB_WH9QULKE,5939
34
+ mdbq/pbix/refresh_all.py,sha256=USe3s5ws2Q-Gp9yUoFOAXJ4t0KVaekFULtAJaZkp448,5976
35
35
  mdbq/spider/__init__.py,sha256=RBMFXGy_jd1HXZhngB2T2XTvJqki8P_Fr-pBcwijnew,18
36
- mdbq-0.3.4.dist-info/METADATA,sha256=1X2UtJWoF55a1DM5zI15bmKJ0-JC3-Vf0YSwHXIxuYE,245
37
- mdbq-0.3.4.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
38
- mdbq-0.3.4.dist-info/top_level.txt,sha256=2FQ-uLnCSB-OwFiWntzmwosW3X2Xqsg0ewh1axsaylA,5
39
- mdbq-0.3.4.dist-info/RECORD,,
36
+ mdbq-0.3.6.dist-info/METADATA,sha256=CYRuia-lwJyJd1vXa7XdTQcidETWAbKSo_Atu5U4tDk,245
37
+ mdbq-0.3.6.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
38
+ mdbq-0.3.6.dist-info/top_level.txt,sha256=2FQ-uLnCSB-OwFiWntzmwosW3X2Xqsg0ewh1axsaylA,5
39
+ mdbq-0.3.6.dist-info/RECORD,,
File without changes