Commit 7995bea2 authored by 赵威's avatar 赵威

update save db

parent 53dd9615
......@@ -10,7 +10,7 @@ import pymysql
from pyspark import SparkConf
from pyspark.sql import SparkSession
from tool import (get_doris_prod, get_jerry_test, get_tag3_user_log, send_email, write_user_portrait,
write_user_portrait_by_event)
write_user_portrait_by_event, write_user_portrait_doris)
# [{'激光': 1.949194898204873}, {'手术': 1.949194898204873}, {'手术': 1.949194898204873}, {'手术': 1.949194898204873, '植发际线': 7.1}]
......@@ -268,6 +268,11 @@ def update_tag3_user_portrait(cl_id):
",".join(first_positions_score.keys()), ",".join(second_positions_score.keys()),
",".join(projects_score.keys()))
write_user_portrait_doris(cl_id, ",".join(first_solutions_score.keys()), ",".join(second_solutions_score.keys()),
",".join(first_demands_score.keys()), ",".join(second_demands_score.keys()),
",".join(first_positions_score.keys()), ",".join(second_positions_score.keys()),
",".join(projects_score.keys()))
return cl_id
......
......@@ -451,6 +451,26 @@ def write_user_portrait(cl_id, first_solutions, second_solutions, first_demands,
print(e)
def write_user_portrait_doris(cl_id, first_solutions, second_solutions, first_demands, second_demands, first_positions,
second_positions, projects):
try:
today = datetime.date.today()
oneday = datetime.timedelta(days=1)
yesterday = today - oneday
sql = """insert into user_tag3_portrait values(null, '{}', '{}', '{}', '{}', '{}', '{}', '{}', '{}', '{}')""".format(
yesterday, cl_id, first_solutions, second_solutions, first_demands, second_demands, first_positions, second_positions,
projects)
db, cursor = get_doris_prod()
cursor.execute(sql)
db.commit()
db.close()
cursor.close()
except Exception as e:
print("write db error")
print(e)
# CREATE TABLE `user_tag3_event_portrait` (
# `id` int(11) NOT NULL AUTO_INCREMENT,
# `date` text NOT NULL,
......
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