Commit d95b6025 by 岳巧源

update class

parent 0be98dd6
Showing with 30 additions and 2 deletions
...@@ -239,6 +239,34 @@ def process_unit_str(attr_name: str) -> str: ...@@ -239,6 +239,34 @@ def process_unit_str(attr_name: str) -> str:
return unit_str return unit_str
def update_pop_class():
ans = get_pop_class()
data = ans["jingdong_vender_category_getFullValidCategoryResultByVenderId_responce"]["returnType"]["list"]
config = config_dev
db = pymysql.connect(host=config["mysql"]["host"],
port=config["mysql"]["port"],
user=config["mysql"]["user"],
database=config["mysql"]["database"],
password=config["mysql"]["password"])
cursor = db.cursor()
for i in range(len(data)):
parent_id = data[i]["fid"]
class_id = data[i]["id"]
class_name = data[i]["name"]
depth = data[i]["lev"]
status = 1
platform = 3
create_time = int(time.time())
# sql = "insert into lie_shop_class (parent_id, class_id, class_name, depth, status, platform, create_time) values (%s, %s, %s, %s, %s, %s, %s)"
select_sql = "select id from lie_shop_class where platform = 3 and class_id = %s"
cursor.execute(query=select_sql)
db_result = cursor.fetchall()
if len(db_result) == 0:
sql = "insert into lie_shop_class (parent_id, class_id, class_name, depth, status, platform, create_time) values (%s, %s, %s, %s, %s, %s, %s)"
cursor.execute(query=sql, args=(parent_id, class_id, class_name, depth, status, platform, create_time))
db.commit()
print(sql % (parent_id, class_id, class_name, depth, status, platform, create_time))
if __name__ == '__main__': if __name__ == '__main__':
handle_pop_unit() update_pop_class()
\ No newline at end of file \ 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 sign in to comment