Commit d713224f authored by 高雅喆's avatar 高雅喆

update

parent 2c0620c3
...@@ -112,24 +112,11 @@ def get_user_service_portrait(cl_id, all_word_tags, all_tag_tag_type, all_3tag_2 ...@@ -112,24 +112,11 @@ def get_user_service_portrait(cl_id, all_word_tags, all_tag_tag_type, all_3tag_2
db_jerry_test.commit() db_jerry_test.commit()
cur_jerry_test.close() cur_jerry_test.close()
db_jerry_test.close() db_jerry_test.close()
# # 写tidb 用户分层营销
# # todo 不准确,因为聚合后,一个标签会有多个来源,即多个pay_type
# score_result = tag_score_sum[["tag2", "cl_id", "tag_score", "weight", "pay_type"]]
# score_result.rename(columns={"tag2": "tag_id", "cl_id": "device_id", "tag_score": "score"}, inplace=True)
# delete_sql = "delete from api_market_personas where device_id='{}'".format(cl_id)
# cur_jerry_test.execute(delete_sql)
# db_jerry_test.commit()
#
# for index, row in score_result.iterrows():
# insert_sql = "insert into api_market_personas values (null, {}, '{}', {}, {}, {})".format(
# row['tag_id'], row['device_id'], row['score'], row['weight'], row['pay_type'])
# cur_jerry_test.execute(insert_sql)
# db_jerry_test.commit()
# db_jerry_test.close()
return cl_id return cl_id
if __name__ == '__main__': if __name__ == '__main__':
try:
db_jerry_test = pymysql.connect(host='172.16.40.170', port=4000, user='root', passwd='3SYz54LS9#^9sBvC', db_jerry_test = pymysql.connect(host='172.16.40.170', port=4000, user='root', passwd='3SYz54LS9#^9sBvC',
db='jerry_test', charset='utf8') db='jerry_test', charset='utf8')
cur_jerry_test = db_jerry_test.cursor() cur_jerry_test = db_jerry_test.cursor()
...@@ -176,3 +163,5 @@ if __name__ == '__main__': ...@@ -176,3 +163,5 @@ if __name__ == '__main__':
# result.foreach(print) # result.foreach(print)
result.collect() result.collect()
spark.stop() spark.stop()
except Exception as e:
pass
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