from pyspark.sql import SQLContext
from pyspark.context import SparkContext
from pyspark.conf import SparkConf

def get_data():
    sc = SparkContext(conf=SparkConf().setAppName("multi_task")).getOrCreate()
    ctx = SQLContext(sc)
    jdbcDf = ctx.read.format("jdbc").options(url="jdbc:mysql://10.66.157.22:4000/jerry_prod",
                                             driver="com.mysql.jdbc.Driver",
                                             dbtable="(select device_id from data_feed_click limit 8) tmp",
                                             user="root",
                                             password="3SYz54LS9#^9sBvC").load()
    jdbcDf.show(6)

if __name__ == '__main__':
    get_data()
