Commit 84509b99 authored by 王志伟's avatar 王志伟
parents 8fa2a506 cf6bc33b
...@@ -95,7 +95,6 @@ def get_data(): ...@@ -95,7 +95,6 @@ def get_data():
train[i] = train[i].map(value_map) train[i] = train[i].map(value_map)
test[i] = test[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(train.shape) print(train.shape)
print("test shape") print("test shape")
......
...@@ -7,8 +7,23 @@ from pyspark.sql import SQLContext ...@@ -7,8 +7,23 @@ from pyspark.sql import SQLContext
from pyspark.sql import SparkSession from pyspark.sql import SparkSession
from py4j.java_gateway import java_import from py4j.java_gateway import java_import
import pytispark.pytispark as pti 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(): def test():
conf = SparkConf().setAppName("My App").set("spark.io.compression.codec", "lzf") conf = SparkConf().setAppName("My App").set("spark.io.compression.codec", "lzf")
...@@ -48,4 +63,10 @@ def esmm_pre(): ...@@ -48,4 +63,10 @@ def esmm_pre():
if __name__ == '__main__': 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