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

change eda

parent 8907f684
...@@ -5,18 +5,13 @@ import numpy as np ...@@ -5,18 +5,13 @@ import numpy as np
import datetime import datetime
import time import time
def con_sql(db,sql):
def con_sql(db, sql):
cursor = db.cursor() cursor = db.cursor()
try: cursor.execute(sql)
cursor.execute(sql) result = cursor.fetchone()[0]
result = cursor.fetchall()
df = pd.DataFrame(list(result)) return result
except Exception:
print("发生异常", Exception)
df = pd.DataFrame()
finally:
db.close()
return df
def test(days): def test(days):
...@@ -25,11 +20,11 @@ def test(days): ...@@ -25,11 +20,11 @@ def test(days):
sql = "select (select count(*) from train_data where stat_date = '{}' and y = 0)/(select count(*) " \ sql = "select (select count(*) from train_data where stat_date = '{}' and y = 0)/(select count(*) " \
"from train_data where stat_date = '{}' and z = 1)".format(start) "from train_data where stat_date = '{}' and z = 1)".format(start)
db = pymysql.connect(host='10.66.157.22', port=4000, user='root', passwd='3SYz54LS9#^9sBvC', db='jerry_test') db = pymysql.connect(host='10.66.157.22', port=4000, user='root', passwd='3SYz54LS9#^9sBvC', db='jerry_test')
exp = con_sql(db, sql)[0].values.tolist()[0] exp = con_sql(db, sql)
print(exp)
sql = "select (select count(*) from train_data where stat_date = '{}' and y = 1 and z = 0)/(select count(*) " \ sql = "select (select count(*) from train_data where stat_date = '{}' and y = 1 and z = 0)/(select count(*) " \
"from train_data where stat_date = '{}' and z = 1)".format(start) "from train_data where stat_date = '{}' and z = 1)".format(start)
db = pymysql.connect(host='10.66.157.22', port=4000, user='root', passwd='3SYz54LS9#^9sBvC', db='jerry_test') click = con_sql(db, sql)
click = con_sql(db, sql)[0].values.tolist()[0]
return start,exp,click return start,exp,click
......
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