Commit 5f59177f authored by 高雅喆's avatar 高雅喆

指标进tidb

parent bbdc3ade
......@@ -433,5 +433,14 @@ if __name__ == '__main__':
log1.info({"比对不上的有画像的人数": result["not_coincide_have_portrait_count"]})
log1.info({"比对不上的无画像的人数": result["not_coincide_no_portrait_count"]})
log1.info("="*66)
# 统计数据进tidb
tplt = "insert into user_portrait_tags_evalution values(null,'{0}','{1}','{2}',{3},{4},{5},{6},{7})"
stat_date = order_date.replace("-", "")
insert_sql = tplt.format(stat_date, "英赫版" if version == 1 else "翔宇版", action_type_detail,
result["device_count"], result["coincide_count"], result["coincide_rate"],
result["not_coincide_have_portrait_count"],
result["not_coincide_no_portrait_count"])
write_data_by_mysql('172.16.40.158', 4000, 'root', '3SYz54LS9#^9sBvC', 'jerry_test', insert_sql)
except Exception as e:
print(e)
\ No newline at end of file
......@@ -60,6 +60,19 @@ def get_data_by_mysql(host, port, user, passwd, db, sql):
print(e)
def write_data_by_mysql(host, port, user, passwd, db, sql):
try:
db = pymysql.connect(host=host, port=port, user=user, passwd=passwd, db=db, cursorclass=pymysql.cursors.DictCursor)
cursor = db.cursor()
cursor.execute(sql)
db.commit()
db.close()
return True
except Exception as e:
print(e)
return False
def get_all_search_word_synonym_tags():
"""
:return:dict {"search_word1":[tag_list1],"search_word2":[tag_list2]...}
......
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