Commit 2762907e authored by 高雅喆's avatar 高雅喆

Merge branch 'master' of git.wanmeizhensuo.com:ML/ffm-baseline

add device map to cid
parents 64fb1491 2a1ff68f
import pymysql
import pandas as pd
def get_data():
db = pymysql.connect(host='10.66.157.22', port=4000, user='root', passwd='3SYz54LS9#^9sBvC', db='eagle')
cursor = db.cursor()
sql = "select native_queue,nearby_queue,nation_queue,megacity_queue,device_id,city_id from ffm_diary_queue;"
cursor.execute(sql)
result = cursor.fetchall()
pd.DataFrame(list(result)).to_csv("/home/gmuser/ffm.csv", index=None)
df = pd.read_csv("/home/gmuser/ffm.csv")
for i in range(df.shape[0]):
a = df.loc[i, :].values
insert(a)
def insert(a):
db = pymysql.connect(host='rm-m5e842126ng59jrv6.mysql.rds.aliyuncs.com', port=3306, user='doris',
passwd='o5gbA27hXHHm',
db='doris_prod')
sql = "INSERT INTO device_diary_queue (native_queue, nearby_queue, nation_queue, " \
"megacity_queue,device_id,city_id) VALUES ('{}','{}','{}','{}','{}','{}');".format \
(a[0], a[1], a[2],a[3],a[4], a[5])
cursor = db.cursor()
cursor.execute(sql)
db.commit()
db.close()
print("end")
if __name__ == "__main__":
get_data()
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