Commit 09c6c9a1 authored by 高雅喆's avatar 高雅喆

update

parent ce335162
...@@ -115,6 +115,8 @@ def get_user_service_portrait(cl_id, all_word_tags, all_tag_tag_type, all_3tag_2 ...@@ -115,6 +115,8 @@ def get_user_service_portrait(cl_id, all_word_tags, all_tag_tag_type, all_3tag_2
.format(stat_date=stat_date, cl_id=cl_id, tag_list=gmkv_tag_score_sum) .format(stat_date=stat_date, cl_id=cl_id, tag_list=gmkv_tag_score_sum)
cur_jerry_test.execute(replace_sql) cur_jerry_test.execute(replace_sql)
db_jerry_test.commit() db_jerry_test.commit()
cur_jerry_test.close()
db_jerry_test.close()
# # 写tidb 用户分层营销 # # 写tidb 用户分层营销
# # todo 不准确,因为聚合后,一个标签会有多个来源,即多个pay_type # # todo 不准确,因为聚合后,一个标签会有多个来源,即多个pay_type
# score_result = tag_score_sum[["tag2", "cl_id", "tag_score", "weight", "pay_type"]] # score_result = tag_score_sum[["tag2", "cl_id", "tag_score", "weight", "pay_type"]]
...@@ -146,6 +148,7 @@ if __name__ == '__main__': ...@@ -146,6 +148,7 @@ if __name__ == '__main__':
cur_jerry_test.execute(sql_device_ids) cur_jerry_test.execute(sql_device_ids)
device_ids_lst = [i[0] for i in cur_jerry_test.fetchall()] device_ids_lst = [i[0] for i in cur_jerry_test.fetchall()]
db_jerry_test.close() db_jerry_test.close()
cur_jerry_test.close()
redis_client = redis.StrictRedis.from_url('redis://:ReDis!GmTx*0aN9@172.16.40.173:6379') redis_client = redis.StrictRedis.from_url('redis://:ReDis!GmTx*0aN9@172.16.40.173:6379')
# 获取搜索词及其近义词对应的tag # 获取搜索词及其近义词对应的tag
......
...@@ -55,6 +55,7 @@ def get_data_by_mysql(host, port, user, passwd, db, sql): ...@@ -55,6 +55,7 @@ def get_data_by_mysql(host, port, user, passwd, db, sql):
cursor.execute(sql) cursor.execute(sql)
results = cursor.fetchall() results = cursor.fetchall()
db.close() db.close()
cursor.close()
return results return results
except Exception as e: except Exception as e:
print(e) print(e)
...@@ -67,6 +68,7 @@ def write_data_by_mysql(host, port, user, passwd, db, sql): ...@@ -67,6 +68,7 @@ def write_data_by_mysql(host, port, user, passwd, db, sql):
cursor.execute(sql) cursor.execute(sql)
db.commit() db.commit()
db.close() db.close()
cursor.close()
return True return True
except Exception as e: except Exception as e:
print(e) print(e)
......
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