Commit 8084e333 by larosa

add update and insert

parent 0c8c6ae3
Showing with 28 additions and 1 deletions
...@@ -5,6 +5,9 @@ import sys ...@@ -5,6 +5,9 @@ import sys
import pymysql import pymysql
from common import request_to_jd_vc from common import request_to_jd_vc
# TODO 通知基石平台告警 ??? 是不是按照原来的方式?? 用is_mapping 字段来进行标识???
config_dev = { config_dev = {
"host": "192.168.1.238", "host": "192.168.1.238",
"port": 3306, "port": 3306,
...@@ -44,10 +47,34 @@ def update_jd_attr_by_class(conf: dict): ...@@ -44,10 +47,34 @@ def update_jd_attr_by_class(conf: dict):
for i in range(len(class_ids)): for i in range(len(class_ids)):
if i != 0: if i != 0:
break break
class_id = class_ids[i]
param = { param = {
"category_leaf_id": class_ids[i] "category_leaf_id": class_id
} }
ans = request_to_jd_vc(method_name=method_name, token=token, app_key=app_key, app_secret=app_secret, param=param) ans = request_to_jd_vc(method_name=method_name, token=token, app_key=app_key, app_secret=app_secret, param=param)
# 处理京东返回的数据 并尝试修改db
jd_results = ans["jingdong_vc_item_props_find_responce"]["jos_result_dto"]["result"]
for j in range(len(jd_results)):
result = jd_results[j]
props = result["props"]
for k in range(len(props)):
prop = props[k]
# 对于 required 为false的数据, 直接跳过,不予处理
if not prop["required"]:
continue
# 对于 input_type 不同的数据 需要采用不同的处理方式。
# 检查这个属性id 是否已经存在(存在的情况会update, 不存在的情况会insert)
attr_id = prop["id"]
check_sql = "select id from lie_shop_attr where class_id = %s and attr_id = %s"
cursor.execute(query=check_sql, args=(class_id, attr_id))
db_result = cursor.fetchall()
if len(db_result) == 0:
pass
else:
pass
......
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 sign in to comment