Commit 0b7df7a5 authored by 张彦钊's avatar 张彦钊

add print

parent b02c21eb
...@@ -10,6 +10,7 @@ from multiprocessing import Pool ...@@ -10,6 +10,7 @@ from multiprocessing import Pool
from config import * from config import *
import json import json
from sklearn.preprocessing import MinMaxScaler from sklearn.preprocessing import MinMaxScaler
import time
def test_con_sql(device_id): def test_con_sql(device_id):
db = pymysql.connect(host='rm-m5e842126ng59jrv6.mysql.rds.aliyuncs.com', port=3306, user='doris', db = pymysql.connect(host='rm-m5e842126ng59jrv6.mysql.rds.aliyuncs.com', port=3306, user='doris',
...@@ -145,15 +146,15 @@ def merge_score(x_list, score_df): ...@@ -145,15 +146,15 @@ def merge_score(x_list, score_df):
cursor.execute(sql) cursor.execute(sql)
result = cursor.fetchall() result = cursor.fetchall()
score = pd.DataFrame(list(result)) score = pd.DataFrame(list(result))
print("数据库日记表前十行") # print("数据库日记表前十行")
print(score) # print(score)
score_list = score[0].values.tolist() score_list = score[0].values.tolist()
db.close() db.close()
score_df["score"] = score_df["score"] + score_list score_df["score"] = score_df["score"] + score_list
print("sum") # print("sum")
print(score_df) # print(score_df)
return score_df return score_df
...@@ -214,6 +215,7 @@ def multi_update(key, name_dict): ...@@ -214,6 +215,7 @@ def multi_update(key, name_dict):
if __name__ == "__main__": if __name__ == "__main__":
start = time.time()
warnings.filterwarnings("ignore") warnings.filterwarnings("ignore")
# TODO 上线后把预测用户改成多进程预测 # TODO 上线后把预测用户改成多进程预测
data_set_cid = pd.read_csv(DIRECTORY_PATH + "data_set_cid.csv")["cid"].values.tolist() data_set_cid = pd.read_csv(DIRECTORY_PATH + "data_set_cid.csv")["cid"].values.tolist()
...@@ -225,6 +227,8 @@ if __name__ == "__main__": ...@@ -225,6 +227,8 @@ if __name__ == "__main__":
for key in name_dict.keys(): for key in name_dict.keys():
multi_update(key, name_dict) multi_update(key, name_dict)
end = time.time()
print(end-start)
# pool = Pool(4) # pool = Pool(4)
# for key in name_dict.keys(): # for key in name_dict.keys():
# pool.apply_async(multi_update,(key,name_dict,)) # pool.apply_async(multi_update,(key,name_dict,))
......
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