mdbq 3.1.2__py3-none-any.whl → 3.1.3__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/mysql/mysql.py +7 -6
- mdbq/mysql/s_query.py +14 -0
- mdbq/other/download_sku_picture.py +0 -6
- mdbq/spider/aikucun.py +1 -1
- {mdbq-3.1.2.dist-info → mdbq-3.1.3.dist-info}/METADATA +1 -1
- {mdbq-3.1.2.dist-info → mdbq-3.1.3.dist-info}/RECORD +8 -8
- {mdbq-3.1.2.dist-info → mdbq-3.1.3.dist-info}/WHEEL +0 -0
- {mdbq-3.1.2.dist-info → mdbq-3.1.3.dist-info}/top_level.txt +0 -0
mdbq/mysql/mysql.py
CHANGED
@@ -324,20 +324,21 @@ class MysqlUpload:
|
|
324
324
|
v = str(float(v.rstrip("%")) / 100)
|
325
325
|
|
326
326
|
result1 = re.findall(r'编码|_?id|货号|款号|文件大小', k, re.IGNORECASE)
|
327
|
-
result2 = re.findall(r'
|
327
|
+
result2 = re.findall(r'占比$|投产$|产出$|roi$|率$', k, re.IGNORECASE)
|
328
|
+
result3 = re.findall(r'同比$|环比$', k, re.IGNORECASE)
|
329
|
+
result4 = re.findall(r'花费$|消耗$|金额$', k, re.IGNORECASE)
|
330
|
+
|
328
331
|
date_type = is_valid_date(v) # 判断日期时间
|
329
332
|
int_num = is_integer(v) # 判断整数
|
330
333
|
count_int, count_float = count_decimal_places(v) # 判断小数,返回小数位数
|
331
334
|
if result1: # 京东sku/spu商品信息
|
332
|
-
__res_dict.update({k: '
|
335
|
+
__res_dict.update({k: 'varchar(100)'})
|
333
336
|
elif k == '日期':
|
334
337
|
__res_dict.update({k: 'DATE'})
|
335
338
|
elif k == '更新时间':
|
336
339
|
__res_dict.update({k: 'TIMESTAMP'})
|
337
|
-
elif str(v) == '':
|
338
|
-
__res_dict.update({k: 'mediumtext'})
|
339
340
|
elif result2: # 小数
|
340
|
-
__res_dict.update({k: 'decimal(
|
341
|
+
__res_dict.update({k: 'decimal(10,4)'})
|
341
342
|
elif date_type == 1: # 纯日期
|
342
343
|
__res_dict.update({k: 'DATE'})
|
343
344
|
elif date_type == 2: # 日期+时间
|
@@ -356,7 +357,7 @@ class MysqlUpload:
|
|
356
357
|
else:
|
357
358
|
__res_dict.update({k: 'decimal(10,2)'})
|
358
359
|
else:
|
359
|
-
__res_dict.update({k: '
|
360
|
+
__res_dict.update({k: 'varchar(255)'})
|
360
361
|
new_dict_data.update({k: v})
|
361
362
|
return __res_dict, new_dict_data
|
362
363
|
|
mdbq/mysql/s_query.py
CHANGED
@@ -35,6 +35,20 @@ class QueryDatas:
|
|
35
35
|
'cursorclass': pymysql.cursors.DictCursor,
|
36
36
|
}
|
37
37
|
|
38
|
+
def check_condition(self, db_name, table_name, condition):
|
39
|
+
""" 按指定条件查询数据库,并返回 """
|
40
|
+
if self.check_infos(db_name, table_name) == False:
|
41
|
+
return
|
42
|
+
|
43
|
+
self.config.update({'database': db_name})
|
44
|
+
connection = pymysql.connect(**self.config) # 重新连接数据库
|
45
|
+
with connection.cursor() as cursor:
|
46
|
+
sql = f"SELECT 更新时间 FROM {table_name} WHERE {condition}"
|
47
|
+
# print(sql)
|
48
|
+
cursor.execute(sql)
|
49
|
+
columns = cursor.fetchall()
|
50
|
+
return columns
|
51
|
+
|
38
52
|
def data_to_df(self, db_name, table_name, start_date, end_date, projection: dict=[]):
|
39
53
|
|
40
54
|
start_date = pd.to_datetime(start_date).strftime('%Y-%m-%d')
|
@@ -958,8 +958,6 @@ def download_spu(username, password, host, port, col_name='白底图', save_path
|
|
958
958
|
从 属性设置 3 -> 商品sku属性 数据库中提取图片地址,下载图片
|
959
959
|
col_name: 从那一列提取图片下载地址 ,, 白底图
|
960
960
|
"""
|
961
|
-
|
962
|
-
# 1. 从商品素材导出中获取数据
|
963
961
|
download = s_query.QueryDatas(username=username, password=password, host=host, port=port)
|
964
962
|
projection = {
|
965
963
|
'日期': 1,
|
@@ -990,10 +988,6 @@ def download_spu(username, password, host, port, col_name='白底图', save_path
|
|
990
988
|
|
991
989
|
|
992
990
|
if __name__ == '__main__':
|
993
|
-
# main(service_name='home_lx', database='mysql')
|
994
|
-
# main2(service_name='home_lx', database='mysql')
|
995
|
-
# main3()
|
996
|
-
# download_sku(service_name='company', database='mysql', db_name='属性设置2', table_name='商品素材下载记录')
|
997
991
|
download_spu(
|
998
992
|
username=username,
|
999
993
|
password=password,
|
mdbq/spider/aikucun.py
CHANGED
@@ -27,12 +27,12 @@ mdbq/log/mylogger.py,sha256=oaT7Bp-Hb9jZt52seP3ISUuxVcI19s4UiqTeouScBO0,3258
|
|
27
27
|
mdbq/mongo/__init__.py,sha256=SILt7xMtQIQl_m-ik9WLtJSXIVf424iYgCfE_tnQFbw,13
|
28
28
|
mdbq/mongo/mongo.py,sha256=v9qvrp6p1ZRWuPpbSilqveiE0FEcZF7U5xUPI0RN4xs,31880
|
29
29
|
mdbq/mysql/__init__.py,sha256=A_DPJyAoEvTSFojiI2e94zP0FKtCkkwKP1kYUCSyQzo,11
|
30
|
-
mdbq/mysql/mysql.py,sha256=
|
30
|
+
mdbq/mysql/mysql.py,sha256=P7--0Unng2b_fYDTyrpU_wQ2SJlqInxVX5xypnLncdM,61027
|
31
31
|
mdbq/mysql/recheck_mysql.py,sha256=rgTpvDMWYTyEn7UQdlig-pdXDluTgiU8JG6lkMh8DV0,8665
|
32
|
-
mdbq/mysql/s_query.py,sha256=
|
32
|
+
mdbq/mysql/s_query.py,sha256=30WilUkm6lsiI5HfGphnnBSVbAXiNsgn2mEPd7AhKJs,9055
|
33
33
|
mdbq/mysql/year_month_day.py,sha256=VgewoE2pJxK7ErjfviL_SMTN77ki8GVbTUcao3vFUCE,1523
|
34
34
|
mdbq/other/__init__.py,sha256=jso1oHcy6cJEfa7udS_9uO5X6kZLoPBF8l3wCYmr5dM,18
|
35
|
-
mdbq/other/download_sku_picture.py,sha256=
|
35
|
+
mdbq/other/download_sku_picture.py,sha256=RnqBp9b5T_I2W_kuiEbxDrTghX4KSktW3Idj3HB9n9g,45769
|
36
36
|
mdbq/other/porxy.py,sha256=UHfgEyXugogvXgsG68a7QouUCKaohTKKkI4RN-kYSdQ,4961
|
37
37
|
mdbq/other/pov_city.py,sha256=AEOmCOzOwyjHi9LLZWPKi6DUuSC-_M163664I52u9qw,21050
|
38
38
|
mdbq/other/sku_picture.py,sha256=JwSXYlzamVqcKCD2tRH2VqYVZNr8fM6f--kcGlTVRnM,50026
|
@@ -44,8 +44,8 @@ mdbq/pbix/refresh_all_old.py,sha256=_pq3WSQ728GPtEG5pfsZI2uTJhU8D6ra-htIk1JXYzw,
|
|
44
44
|
mdbq/req_post/__init__.py,sha256=jso1oHcy6cJEfa7udS_9uO5X6kZLoPBF8l3wCYmr5dM,18
|
45
45
|
mdbq/req_post/req_tb.py,sha256=qg7pet73IgKGmCwxaeUyImJIoeK_pBQT9BBKD7fkBNg,36160
|
46
46
|
mdbq/spider/__init__.py,sha256=RBMFXGy_jd1HXZhngB2T2XTvJqki8P_Fr-pBcwijnew,18
|
47
|
-
mdbq/spider/aikucun.py,sha256=
|
48
|
-
mdbq-3.1.
|
49
|
-
mdbq-3.1.
|
50
|
-
mdbq-3.1.
|
51
|
-
mdbq-3.1.
|
47
|
+
mdbq/spider/aikucun.py,sha256=48isoL6nEi_uniV-ja2HwYAI7O8D1i1goO4SzBwDGSU,19036
|
48
|
+
mdbq-3.1.3.dist-info/METADATA,sha256=lodcRj-xLO50k20i02W_yzinH0gVePTof0hc556ob60,243
|
49
|
+
mdbq-3.1.3.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
50
|
+
mdbq-3.1.3.dist-info/top_level.txt,sha256=2FQ-uLnCSB-OwFiWntzmwosW3X2Xqsg0ewh1axsaylA,5
|
51
|
+
mdbq-3.1.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|