Commit 16a37cad by 岳巧源

add handle unit

parent 7ad48f6b
Showing with 26 additions and 0 deletions
...@@ -441,6 +441,31 @@ def update_vc_ext_redis(conf: dict): ...@@ -441,6 +441,31 @@ def update_vc_ext_redis(conf: dict):
print("jd_ext_attr", key, value) print("jd_ext_attr", key, value)
def handle_default_unit(conf: dict):
"""
保持unit与default_unit一致。
"""
host = conf["mysql"]["host"]
port = conf["mysql"]["port"]
user = conf["mysql"]["user"]
password = conf["mysql"]["password"]
database = conf["mysql"]["database"]
db = pymysql.connect(host=host, port=port, user=user, password=password, database=database)
cursor = db.cursor()
select_sql = "select id, unit from lie_shop_attr where platform = 1 and unit = '' and default_unit != ''"
cursor.execute(query=select_sql)
db_result = cursor.fetchall()
for i in range(len(db_result)):
id = db_result[i][0]
update_sql = "update lie_shop_attr set default_unit = '' where id = %s"
cursor.execute(query=update_sql, args=(id,))
db.commit()
print(update_sql % (id))
""" """
执行命令 执行命令
线上:python3 crontab.py prod 线上:python3 crontab.py prod
...@@ -467,5 +492,6 @@ if __name__ == '__main__': ...@@ -467,5 +492,6 @@ if __name__ == '__main__':
update_vc_ext_redis(config) update_vc_ext_redis(config)
print("========================> redis中拓展参数更新完毕") print("========================> redis中拓展参数更新完毕")
handle_vc_unit(config) handle_vc_unit(config)
handle_default_unit(config)
print("========================> 单位处理完毕") print("========================> 单位处理完毕")
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