Commit eed064fe authored by 张彦钊's avatar 张彦钊

修改sql

parent 524fde45
......@@ -3,7 +3,6 @@ import pymysql
import datetime
import pandas as pd
DIRECTORY_PATH="/data/ffm/"
def get_yesterday_date():
today = datetime.date.today()
......@@ -19,22 +18,22 @@ def get_data():
sql = "select device_id from ffm_diary_queue where device_id regexp '[5|6]$'"
cursor.execute(sql)
result = cursor.fetchall()
device_id = tuple(pd.DataFrame(list(result))[0].values.tolist())
device = tuple(pd.DataFrame(list(result))[0].values.tolist())
cursor.close()
print(device_id[0:2])
print(device[0:2])
return device_id
return device
def ctr_all():
db = pymysql.connect(host='10.66.157.22', port=4000, user='root', passwd='3SYz54LS9#^9sBvC', db='jerry_prod')
cursor = db.cursor()
sql_active = "select distinct device_id from data_feed_exposure where (cid_type = 'diary' or cid_type = 'diary_video') " \
"and device_id regexp'[5|6]$' and stat_date = '{}';".format(date)
sql_active = "select distinct device_id from data_feed_exposure " \
"where cid_type = 'diary' and device_id regexp'[5|6]$' and stat_date = '{}';".format(date)
cursor.execute(sql_active)
result = cursor.fetchall()
tail56 = tuple(pd.DataFrame(list(result))[0].values.tolist())
start = "2012-09-05"
tail56 = pd.DataFrame(list(result))[0].values.tolist()
start = "2018-09-05"
sql_all = "select distinct device_id from data_feed_click " \
"where stat_date >= '{}' and stat_date <= '{}' and cid_type = 'diary'".format(start,date)
cursor.execute(sql_all)
......@@ -96,7 +95,9 @@ def rate2file():
+","+str(data[5])+'\n'
f.write(line)
if __name__ == "__main__":
DIRECTORY_PATH = "/data/ffm/"
date = get_yesterday_date()
device_id = get_data()
temp_data = ctr()
......
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