mdbq 4.0.11__tar.gz → 4.0.13__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 (35) hide show
  1. {mdbq-4.0.11 → mdbq-4.0.13}/PKG-INFO +1 -1
  2. mdbq-4.0.13/mdbq/__version__.py +1 -0
  3. {mdbq-4.0.11 → mdbq-4.0.13}/mdbq/aggregation/query_data.py +9 -6
  4. {mdbq-4.0.11 → mdbq-4.0.13}/mdbq/mysql/deduplicator.py +7 -3
  5. {mdbq-4.0.11 → mdbq-4.0.13}/mdbq/mysql/s_query.py +7 -3
  6. {mdbq-4.0.11 → mdbq-4.0.13}/mdbq/mysql/unique_.py +7 -3
  7. {mdbq-4.0.11 → mdbq-4.0.13}/mdbq/mysql/uploader.py +7 -3
  8. {mdbq-4.0.11 → mdbq-4.0.13}/mdbq/other/download_sku_picture.py +8 -5
  9. {mdbq-4.0.11 → mdbq-4.0.13}/mdbq/spider/aikucun.py +7 -4
  10. {mdbq-4.0.11 → mdbq-4.0.13}/mdbq.egg-info/PKG-INFO +1 -1
  11. {mdbq-4.0.11 → mdbq-4.0.13}/mdbq.egg-info/SOURCES.txt +0 -2
  12. mdbq-4.0.11/mdbq/__version__.py +0 -1
  13. mdbq-4.0.11/mdbq/config/config.py +0 -95
  14. mdbq-4.0.11/mdbq/other/__init__.py +0 -4
  15. {mdbq-4.0.11 → mdbq-4.0.13}/README.txt +0 -0
  16. {mdbq-4.0.11 → mdbq-4.0.13}/mdbq/__init__.py +0 -0
  17. {mdbq-4.0.11 → mdbq-4.0.13}/mdbq/aggregation/__init__.py +0 -0
  18. {mdbq-4.0.11 → mdbq-4.0.13}/mdbq/log/__init__.py +0 -0
  19. {mdbq-4.0.11 → mdbq-4.0.13}/mdbq/log/mylogger.py +0 -0
  20. {mdbq-4.0.11 → mdbq-4.0.13}/mdbq/mysql/__init__.py +0 -0
  21. {mdbq-4.0.11 → mdbq-4.0.13}/mdbq/mysql/mysql.py +0 -0
  22. {mdbq-4.0.11/mdbq/config → mdbq-4.0.13/mdbq/other}/__init__.py +0 -0
  23. {mdbq-4.0.11 → mdbq-4.0.13}/mdbq/other/otk.py +0 -0
  24. {mdbq-4.0.11 → mdbq-4.0.13}/mdbq/other/pov_city.py +0 -0
  25. {mdbq-4.0.11 → mdbq-4.0.13}/mdbq/other/ua_sj.py +0 -0
  26. {mdbq-4.0.11 → mdbq-4.0.13}/mdbq/pbix/__init__.py +0 -0
  27. {mdbq-4.0.11 → mdbq-4.0.13}/mdbq/pbix/pbix_refresh.py +0 -0
  28. {mdbq-4.0.11 → mdbq-4.0.13}/mdbq/pbix/refresh_all.py +0 -0
  29. {mdbq-4.0.11 → mdbq-4.0.13}/mdbq/redis/__init__.py +0 -0
  30. {mdbq-4.0.11 → mdbq-4.0.13}/mdbq/redis/getredis.py +0 -0
  31. {mdbq-4.0.11 → mdbq-4.0.13}/mdbq/spider/__init__.py +0 -0
  32. {mdbq-4.0.11 → mdbq-4.0.13}/mdbq.egg-info/dependency_links.txt +0 -0
  33. {mdbq-4.0.11 → mdbq-4.0.13}/mdbq.egg-info/top_level.txt +0 -0
  34. {mdbq-4.0.11 → mdbq-4.0.13}/setup.cfg +0 -0
  35. {mdbq-4.0.11 → mdbq-4.0.13}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: mdbq
3
- Version: 4.0.11
3
+ Version: 4.0.13
4
4
  Home-page: https://pypi.org/project/mdbq
5
5
  Author: xigua,
6
6
  Author-email: 2587125111@qq.com
@@ -0,0 +1 @@
1
+ VERSION = '4.0.13'
@@ -3,7 +3,7 @@ import re
3
3
  # from mdbq.mysql import mysql
4
4
  from mdbq.mysql import uploader
5
5
  from mdbq.mysql import s_query
6
- from mdbq.config import config
6
+ from mdbq.conf import conf
7
7
  from mdbq.log import mylogger
8
8
  import datetime
9
9
  from dateutil.relativedelta import relativedelta
@@ -18,10 +18,13 @@ from collections.abc import Mapping, Sequence
18
18
  import inspect
19
19
 
20
20
  dir_path = os.path.expanduser("~")
21
- config_file = os.path.join(dir_path, 'spd.txt')
22
- content = config.read_config(file_path=config_file)
23
- username, password, host, port = content['username'], content['password'], content['host'], content['port']
24
- host = 'localhost'
21
+ parser = conf.ConfigParser()
22
+ host, port, username, password = parser.get_section_values(
23
+ file_path=os.path.join(dir_path, 'spd.txt'),
24
+ section='mysql',
25
+ keys=['host', 'port', 'username', 'password'],
26
+ )
27
+ # host = 'localhost'
25
28
  uld = uploader.MySQLUploader(username=username, password=password, host=host, port=int(port), pool_size=10)
26
29
 
27
30
  logger = mylogger.MyLogger(
@@ -3685,7 +3688,7 @@ def main(months=3):
3685
3688
  password=password,
3686
3689
  host=host,
3687
3690
  port=port,
3688
- maxconnections=20,
3691
+ pool_size=20,
3689
3692
  )
3690
3693
  query1(download_manager=download_manager, months=months)
3691
3694
  query2(download_manager=download_manager, months=months)
@@ -6,7 +6,7 @@ import warnings
6
6
  import pymysql
7
7
  import os
8
8
  from mdbq.log import mylogger
9
- from mdbq.config import config
9
+ from mdbq.conf import conf
10
10
  from typing import List, Dict, Optional, Any, Tuple
11
11
  from dbutils.pooled_db import PooledDB
12
12
  import threading
@@ -1351,8 +1351,12 @@ class MySQLDeduplicator:
1351
1351
  def main():
1352
1352
  logger.info('去重任务开始')
1353
1353
  dir_path = os.path.expanduser("~")
1354
- my_cont = config.read_config(file_path=os.path.join(dir_path, 'spd.txt'))
1355
- username, password, host, port = my_cont['username'], my_cont['password'], my_cont['host'], int(my_cont['port'])
1354
+ parser = conf.ConfigParser()
1355
+ host, port, username, password = parser.get_section_values(
1356
+ file_path=os.path.join(dir_path, 'spd.txt'),
1357
+ section='mysql',
1358
+ keys=['host', 'port', 'username', 'password'],
1359
+ )
1356
1360
  # host = 'localhost'
1357
1361
 
1358
1362
  deduplicator = MySQLDeduplicator(
@@ -7,7 +7,7 @@ from decimal import Decimal
7
7
  from contextlib import closing
8
8
  from mdbq.log import mylogger
9
9
  import os
10
- from mdbq.config import config
10
+ from mdbq.conf import conf
11
11
  from typing import Optional, Dict, List, Set, Tuple, Union, Any, Literal
12
12
  from dbutils.pooled_db import PooledDB
13
13
  import time
@@ -949,8 +949,12 @@ class QueryDatas:
949
949
 
950
950
  def main():
951
951
  dir_path = os.path.expanduser("~")
952
- my_cont = config.read_config(file_path=os.path.join(dir_path, 'spd.txt'))
953
- username, password, host, port = my_cont['username'], my_cont['password'], my_cont['host'], int(my_cont['port'])
952
+ parser = conf.ConfigParser()
953
+ host, port, username, password = parser.get_section_values(
954
+ file_path=os.path.join(dir_path, 'spd.txt'),
955
+ section='mysql',
956
+ keys=['host', 'port', 'username', 'password'],
957
+ )
954
958
  host = 'localhost'
955
959
 
956
960
  qd = QueryDatas(username=username, password=password, host=host, port=port)
@@ -2,7 +2,7 @@ import re
2
2
  import pymysql
3
3
  from typing import List, Dict, Any, Tuple
4
4
  from mdbq.log import mylogger
5
- from mdbq.config import config
5
+ from mdbq.conf import conf
6
6
  from dbutils.pooled_db import PooledDB
7
7
  import os
8
8
 
@@ -274,8 +274,12 @@ class UniqueManager:
274
274
 
275
275
  def main():
276
276
  dir_path = os.path.expanduser("~")
277
- my_cont = config.read_config(file_path=os.path.join(dir_path, 'spd.txt'))
278
- username, password, host, port = my_cont['username'], my_cont['password'], my_cont['host'], int(my_cont['port'])
277
+ parser = conf.ConfigParser()
278
+ host, port, username, password = parser.get_section_values(
279
+ file_path=os.path.join(dir_path, 'spd.txt'),
280
+ section='mysql',
281
+ keys=['host', 'port', 'username', 'password'],
282
+ )
279
283
  # host = 'localhost'
280
284
 
281
285
  my_databases = [
@@ -8,7 +8,7 @@ import pymysql
8
8
  import pandas as pd
9
9
  import os
10
10
  from mdbq.log import mylogger
11
- from mdbq.config import config
11
+ from mdbq.conf import conf
12
12
  from typing import Union, List, Dict, Optional, Any, Tuple, Set
13
13
  from dbutils.pooled_db import PooledDB
14
14
  import json
@@ -1737,8 +1737,12 @@ class MySQLUploader:
1737
1737
 
1738
1738
  def main():
1739
1739
  dir_path = os.path.expanduser("~")
1740
- my_cont = config.read_config(file_path=os.path.join(dir_path, 'spd.txt'))
1741
- username, password, host, port = my_cont['username'], my_cont['password'], my_cont['host'], int(my_cont['port'])
1740
+ parser = conf.ConfigParser()
1741
+ host, port, username, password = parser.get_section_values(
1742
+ file_path=os.path.join(dir_path, 'spd.txt'),
1743
+ section='mysql',
1744
+ keys=['host', 'port', 'username', 'password'],
1745
+ )
1742
1746
  host = 'localhost'
1743
1747
 
1744
1748
  uploader = MySQLUploader(
@@ -17,8 +17,7 @@ from selenium.webdriver.support.wait import WebDriverWait
17
17
  from selenium.webdriver.common.by import By
18
18
  from selenium.webdriver.support import expected_conditions as EC
19
19
  from selenium.webdriver.chrome.service import Service
20
- from mdbq.config import set_support
21
- from mdbq.config import config
20
+ from mdbq.conf import conf
22
21
  from mdbq.mysql import mysql
23
22
  from mdbq.mysql import s_query
24
23
  from mdbq.other import ua_sj
@@ -49,8 +48,12 @@ if not os.path.exists(upload_path): # 数据中心根目录
49
48
 
50
49
  dir_path = os.path.expanduser("~")
51
50
  config_file = os.path.join(dir_path, 'spd.txt')
52
- content = config.read_config(file_path=config_file)
53
- username, password, host, port = content['username'], content['password'], content['host'], content['port']
51
+ parser = conf.ConfigParser()
52
+ host, port, username, password = parser.get_section_values(
53
+ file_path=config_file,
54
+ section='mysql',
55
+ keys=['host', 'port', 'username', 'password'],
56
+ )
54
57
  m_engine = mysql.MysqlUpload(username=username, password=password, host=host, port=port, charset='utf8mb4')
55
58
 
56
59
  if not username:
@@ -62,7 +65,7 @@ class LoadAccount:
62
65
 
63
66
  def __init__(self):
64
67
  self.url = 'https://login.taobao.com/' # 默认登录淘宝
65
- self.cookie_path = os.path.join(set_support.SetSupport(dirname='support').dirname, 'cookies')
68
+ self.cookie_path = None
66
69
 
67
70
  def __call__(self, *args, **kwargs):
68
71
  self.check_cookie() # 检测cookie有效期, 但不阻断任务
@@ -15,15 +15,18 @@ from selenium.webdriver.chrome.service import Service
15
15
  import pymysql
16
16
  from mdbq.mysql import uploader
17
17
  from mdbq.mysql import s_query
18
- from mdbq.config import config
18
+ from mdbq.conf import conf
19
19
  from mdbq.other import ua_sj
20
20
  from mdbq.other import otk
21
21
  from mdbq.log import mylogger
22
22
 
23
23
  dir_path = os.path.expanduser("~")
24
- config_file = os.path.join(dir_path, 'spd.txt')
25
- content = config.read_config(file_path=config_file)
26
- username, password, host, port = content['username'], content['password'], content['host'], content['port']
24
+ parser = conf.ConfigParser()
25
+ host, port, username, password = parser.get_section_values(
26
+ file_path=os.path.join(dir_path, 'spd.txt'),
27
+ section='mysql',
28
+ keys=['host', 'port', 'username', 'password'],
29
+ )
27
30
 
28
31
  # 实例化一个数据查询类,用来获取 cookies 表数据
29
32
  logger = mylogger.MyLogger(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: mdbq
3
- Version: 4.0.11
3
+ Version: 4.0.13
4
4
  Home-page: https://pypi.org/project/mdbq
5
5
  Author: xigua,
6
6
  Author-email: 2587125111@qq.com
@@ -8,8 +8,6 @@ mdbq.egg-info/dependency_links.txt
8
8
  mdbq.egg-info/top_level.txt
9
9
  mdbq/aggregation/__init__.py
10
10
  mdbq/aggregation/query_data.py
11
- mdbq/config/__init__.py
12
- mdbq/config/config.py
13
11
  mdbq/log/__init__.py
14
12
  mdbq/log/mylogger.py
15
13
  mdbq/mysql/__init__.py
@@ -1 +0,0 @@
1
- VERSION = '4.0.11'
@@ -1,95 +0,0 @@
1
- import os.path
2
- import re
3
-
4
-
5
- def read_config(file_path):
6
- """读取配置文件,返回字典"""
7
- if not os.path.isfile(file_path):
8
- print(f'配置文件不存在: {file_path}')
9
- return
10
- config = {}
11
- with open(file_path, 'r', encoding='utf-8') as file:
12
- for line in file:
13
- stripped_line = line.strip()
14
- # 跳过空行和注释行(以 # 或 // 开头)
15
- if not stripped_line or stripped_line.startswith(('#', '//')):
16
- continue
17
- # 处理行内注释(# 或 // 前有空格)
18
- comment_match = re.search(r'\s+[#//]', line)
19
- if comment_match:
20
- line = line[:comment_match.start()].strip()
21
- else:
22
- line = line.strip()
23
- # 解析键值对
24
- if '=' in line:
25
- key, value = line.split('=', 1)
26
- config[key.strip()] = value.strip()
27
- return config
28
-
29
-
30
- def write_config(file_path, rewrite):
31
- """
32
- 更新配置文件中的键值对,保留注释和其他内容,修复等号空格问题
33
- 示例:
34
- write_config('spd.txt', {'is_spider': True})
35
- """
36
- # 读取所有行到内存
37
- try:
38
- with open(file_path, 'r', encoding='utf-8') as file:
39
- lines = file.readlines()
40
- except FileNotFoundError:
41
- with open(file_path, 'w', encoding='utf-8') as file:
42
- lines = []
43
-
44
- new_lines = []
45
- found_keys = set()
46
-
47
- for line in lines:
48
- stripped = line.strip()
49
- if not stripped or stripped.startswith(('#', '//')):
50
- new_lines.append(line)
51
- continue
52
-
53
- # 使用 partition 保留等号格式
54
- key_part, sep, value_part = line.partition('=')
55
- if not sep: # 没有等号的行直接保留
56
- new_lines.append(line)
57
- continue
58
-
59
- key = key_part.strip()
60
- if key in rewrite:
61
- # 处理值部分和注释
62
- comment_match = re.search(r'\s+([#//].*)$', value_part)
63
- if comment_match:
64
- comment = comment_match.group(0)
65
- raw_value = value_part[:comment_match.start()].rstrip()
66
- else:
67
- comment = ''
68
- raw_value = value_part.strip()
69
-
70
- # 保留原值前导空格
71
- leading_space = re.match(r'^(\s*)', value_part).group(1)
72
- new_value = f"{leading_space}{rewrite[key]}{comment}"
73
-
74
- # 构建新行(保留原等号格式)
75
- new_line = f"{key_part}{sep}{new_value}\n"
76
- new_lines.append(new_line)
77
- found_keys.add(key)
78
- else:
79
- new_lines.append(line)
80
-
81
- # 添加新键值对
82
- for key in rewrite:
83
- if key not in found_keys:
84
- new_lines.append(f"{key} = {rewrite[key]}\n")
85
-
86
- # 写入文件
87
- with open(file_path, 'w', encoding='utf-8') as file:
88
- file.writelines(new_lines)
89
-
90
-
91
- if __name__ == '__main__':
92
- res = read_config('/Users/xigua/数据中心2/spider/spd.txt')
93
- print(res)
94
- # write_config('spd.txt', {'is_spider': False})
95
-
@@ -1,4 +0,0 @@
1
-
2
-
3
-
4
- # 配置文件
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