Commit 0bc1fce7 authored by sanlu's avatar sanlu

修改了读取子类对应的表

parent 3165d73c
......@@ -389,8 +389,7 @@ class data_fetch():
data = self.sql_LXWL.cursor.fetchall()[0]
data = list(data)
symbol = 0
#sql_ZIdatabase.cursor.execute(f'select * from Product_Relation_Attribute_SubTitle where SourceSubCategory={data[3]}')
'''
self.sql_ZIdatabase_local.cursor.execute(f"select ZI_SubCategoryCode,ZI_SubTitle from Product_Relation_Attribute_SubTitle where SourceSubCategory='{data[3]}' and Source='{self.channel}'")
try:
ZI_SubCategoryCode = self.sql_ZIdatabase_local.cursor.fetchone()[0]
......@@ -400,7 +399,6 @@ class data_fetch():
ZI_SubCategoryCode = self.sql_ZIdatabase_local.cursor.fetchone()[0]
except TypeError:
ZI_SubCategoryCode = '没有匹配的指数子类编码'
symbol = 1
data.append(ZI_SubCategoryCode)
if ZI_SubCategoryCode != '没有匹配的指数子类编码':
......@@ -408,6 +406,19 @@ class data_fetch():
ZIname = self.sql_ZIdatabase_local.cursor.fetchone()[0]
else:
ZIname = '没有匹配的指数子类编码'
'''
self.sql_LXWL.cursor.execute(f"select zi_subcategoryname,zi_subcategorycode from product_all where sku='{sku}'")
ZI_SubCategory_data = self.sql_LXWL.cursor.fetchone()
if ZI_SubCategory_data[1] is None:
ZI_SubCategoryCode = '没有匹配的指数子类编码'
else:
ZI_SubCategoryCode = ZI_SubCategory_data[1]
data.append(ZI_SubCategoryCode)
if ZI_SubCategory_data[0] is None:
ZIname = '没有匹配的指数子类编码'
else:
ZIname = ZI_SubCategory_data[0]
self.sql_LXWL.cursor.execute(f"select title,value from info_detail where sku='{sku}'")
params = self.sql_LXWL.cursor.fetchall()
......@@ -443,6 +454,7 @@ class data_fetch():
data.append(ZIname)
data.append(ZIbrand)
self.sql_LXWL.cursor.execute(f"update product_all set state='8' where sku='{sku}'")
return data
......@@ -564,7 +576,7 @@ class data_fetch():
return data_table
if __name__ == '__main__':
'''
thread_DL = myThread('DL')
thread_DZ = myThread('DZ')
thread_YHD = myThread('YHD')
......@@ -588,8 +600,7 @@ if __name__ == '__main__':
print('完毕!')
'''
channel = 'SN'
channel = 'DL'
data_api = data_fetch(model='LXWL_model', localhost=False, source=f'ZH_{channel}')
data_api_table = data_api.run()
#param_extract_function(data_api_table,channel)
'''
\ No newline at end of file
......@@ -2,19 +2,8 @@ import pandas as pd
import time
from function import *
def return_error(table):
sql_zi_zh = sql_find('zi_zh', False)
NowTime = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime())
#table = pd.read_excel('api_data/ZH_SN_no_category_data_2019-12-27.xlsx', dtype = {'SKU' : str})
table = table[['SKU','产品名称','url','来源']]
l = len(table)
create_time_list = []
remark_list = []
for i in range(l):
create_time_list.append(NowTime)
remark_list.append('类别对应错误')
table['remark'] = remark_list
table['create_time'] = create_time_list
table.columns = ['sku','name','url','source','remark','create_time']
table.to_sql('API_returnErrorData', sql_zi_zh.engine, if_exists='append', index=False)
\ No newline at end of file
sql_LXWL = sql_find('ZH_DL', False)
sku = '101016853PCS'
sql_LXWL.cursor.execute(f"select zi_subcategoryname,zi_subcategorycode from product_all where sku='{sku}'")
ZI_SubCategory_data = sql_LXWL.cursor.fetchone()
print(ZI_SubCategory_data[0] is None)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment