Commit d787c2fd authored by litaolemo's avatar litaolemo

update

parent 2caa1fe4
......@@ -183,46 +183,47 @@ WHERE spam_pv.device_id IS NULL
for count, res in enumerate(sql_res):
# print(count, res)
portratit_res = get_user_portrait_tag3_from_redis(res)
print(count, res , portratit_res)
res_dict = {}
if portratit_res:
print(count, res, portratit_res)
# res_dict = {}
#
print("-------------------------------")
for count, res in enumerate(sql_res):
# print(count, res)
track = res.track
if not track:
continue
track_list = track.split(",")
for one_key_word in track_list:
if one_key_word in res_dict:
res_dict[one_key_word] += 1
else:
res_dict[one_key_word] = 1
print(res_dict)
exception_list = ("report_status","is_open_push")
for action in res_dict:
partition_date = yesterday_str
pid = hashlib.md5((partition_date + action).encode("utf8")).hexdigest()
action_count = res_dict[action]
action_ch = name_dict.get(action)
if not action_ch:
action_ch = action
if action_ch in exception_list:
continue
instert_sql = """replace into new_user_click_count(
partition_day,pid,action_count,action_ch,action) VALUES('{partition_day}','{pid}',{action_count},'{action_ch}','{action}');""".format(
partition_date=partition_date, partition_day=yesterday_str, pid=pid, action_count=action_count,
action_ch=action_ch, action=action
)
print(instert_sql)
# cursor.execute("set names 'UTF8'")
db = pymysql.connect(host='172.16.40.158', port=4000, user='st_user', passwd='aqpuBLYzEV7tML5RPsN1pntUzFy',
db='jerry_prod')
cursor = db.cursor()
res = cursor.execute(instert_sql)
db.commit()
print(res)
# cursor.executemany()
db.close()
# for count, res in enumerate(sql_res):
# # print(count, res)
# track = res.track
# if not track:
# continue
# track_list = track.split(",")
# for one_key_word in track_list:
# if one_key_word in res_dict:
# res_dict[one_key_word] += 1
# else:
# res_dict[one_key_word] = 1
# print(res_dict)
#
# exception_list = ("report_status","is_open_push")
# for action in res_dict:
# partition_date = yesterday_str
# pid = hashlib.md5((partition_date + action).encode("utf8")).hexdigest()
# action_count = res_dict[action]
# action_ch = name_dict.get(action)
# if not action_ch:
# action_ch = action
# if action_ch in exception_list:
# continue
# instert_sql = """replace into new_user_click_count(
# partition_day,pid,action_count,action_ch,action) VALUES('{partition_day}','{pid}',{action_count},'{action_ch}','{action}');""".format(
# partition_date=partition_date, partition_day=yesterday_str, pid=pid, action_count=action_count,
# action_ch=action_ch, action=action
# )
# print(instert_sql)
# # cursor.execute("set names 'UTF8'")
# db = pymysql.connect(host='172.16.40.158', port=4000, user='st_user', passwd='aqpuBLYzEV7tML5RPsN1pntUzFy',
# db='jerry_prod')
# cursor = db.cursor()
# res = cursor.execute(instert_sql)
# db.commit()
# print(res)
# # cursor.executemany()
# db.close()
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 to comment