Commit 593d3097 authored by 张彦钊's avatar 张彦钊

修改test文件

parent e87b46e6
......@@ -95,7 +95,6 @@ def get_data():
train[i] = train[i].map(value_map)
test[i] = test[i].map(value_map)
print(train[["clevel2_id", "channel","app_list"]].head(6))
print("train shape")
print(train.shape)
print("test shape")
......
......@@ -7,8 +7,23 @@ from pyspark.sql import SQLContext
from pyspark.sql import SparkSession
from py4j.java_gateway import java_import
import pytispark.pytispark as pti
import pandas as pd
import pymysql
def con_sql(db,sql):
cursor = db.cursor()
try:
cursor.execute(sql)
result = cursor.fetchall()
df = pd.DataFrame(list(result))
except Exception:
print("发生异常", Exception)
df = pd.DataFrame()
finally:
db.close()
return df
def test():
conf = SparkConf().setAppName("My App").set("spark.io.compression.codec", "lzf")
......@@ -48,4 +63,10 @@ def esmm_pre():
if __name__ == '__main__':
esmm_pre()
try:
db = pymysql.connect(host='10.66.157.11', port=4000, user='root', passwd='3SYz54LS9#^9sBvC', db='jerry_test')
except Exception:
db = pymysql.connect(host='10.66.157.22', port=4000, user='root', passwd='3SYz54LS9#^9sBvC', db='jerry_test')
sql = "select max(stat_date) from esmm_train_data"
validate_date = con_sql(db, sql)[0].values.tolist()[0]
print("validate_date:" + validate_date)
\ No newline at end of file
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