Commit e2441919 by 岳巧源

script

parent f79a279d
Showing with 40 additions and 0 deletions
import json
import pymysql
if __name__ == '__main__':
conf = {
'host': "192.168.1.238",
'port': 3306,
'user': "europa_erp",
'password': "europa_erp#zsyM",
'db': "europa_erp",
'charset': 'utf8'
}
db = pymysql.connect(**conf)
cursor = db.cursor()
sql = "select * from erp_goods_sku where supplier_id = 24"
cursor.execute(sql)
result = cursor.fetchall()
for i in range(len(result)):
sku_id = str(result[i][0])
ladder_price = result[i][19]
ans = json.loads(ladder_price)
change_arr = []
print(ladder_price)
for j in range(len(ans)):
if 'price_cn' in ans[j]:
ans[j]['price_cn'] = 0
change_arr.append(ans[j])
print(change_arr)
if len(change_arr) != 0:
new_ladder_price = json.dumps(change_arr)
update_sql = "update erp_goods_sku set ladder_price = %s where sku_id = %s limit 1"
try:
cursor.execute(update_sql, [str(new_ladder_price), sku_id])
db.commit()
except Exception as e:
db.rollback()
print(e)
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