Commit 0ef48f57 by larosa

add default unit

parent 65e946b0
Showing with 59 additions and 7 deletions
......@@ -2,16 +2,68 @@
import json
import pymysql
from common import request_to_jd_vc
config_dev = {
"mysql": {
"host": "192.168.1.238",
"port": 3306,
"user": "liexin_data_distribution",
"password": "liexin_data_distribution#zsyM",
"database": "liexin_data_distribution"
},
"redis": {
"host": "192.168.1.235",
"port": 6379,
"password": "icDb29mLy2s"
}
}
config_prod = {
"mysql": {
"host": "bigdata2.ichunt.db",
"port": 3306,
"user": "DsbuUx",
"password": "sfj09JjsfpQx0",
"database": "liexin_data_distribution"
},
"redis": {
"host": "172.18.137.38",
"port": 6379,
"password": "icDb29mLy2s"
}
}
def main():
method_name = "jingdong.vc.item.brands.find"
token = "845ce8478b074103b9e78a769d5fa4831y2u"
app_key = "CA52430E90209F51D8F5D7B615DDE9AD"
app_secret = "c92691b2379c48de87e699c4c2f7fb32"
param = {}
ans = request_to_jd_vc(method_name, token, app_key, app_secret, param)
print(json.dumps(ans, ensure_ascii=False))
"""将unit单位移动到default_unit"""
conf = config_prod
db = pymysql.connect(host=conf["mysql"]["host"], port=conf["mysql"]["port"], user=conf["mysql"]["user"], password=conf["mysql"]["password"], database=conf["mysql"]["database"])
cursor = db.cursor()
select_sql = "select id, unit from lie_shop_attr where platform = 1 and input_type = 7"
cursor.execute(query=select_sql)
db_result = cursor.fetchall()
for i in range(len(db_result)):
id = db_result[i][0]
default_unit = db_result[i][1]
update_sql = "update lie_shop_attr set default_unit = %s where id = %s"
cursor.execute(query=update_sql, args=(default_unit, id,))
db.commit()
print(update_sql % (default_unit, id))
select_sql = "select id, unit from lie_shop_attr where platform = 1 and input_type = 10"
cursor.execute(query=select_sql)
db_result = cursor.fetchall()
for i in range(len(db_result)):
id = db_result[i][0]
unit = db_result[i][1]
end = str(unit).find(",")
default_unit = unit[2:end-1]
update_sql = "update lie_shop_attr set default_unit = %s where id = %s"
cursor.execute(query=update_sql, args=(default_unit, id, ))
print(update_sql % (default_unit, id))
db.commit()
if __name__ == '__main__':
......
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