读取mysql

from pyspark.sql import SparkSession
from pyspark.conf import SparkConf
from pyspark.sql import SQLContext

conf = SparkConf().setAppName('数据总览')
spark = SparkSession.builder.config(conf=conf).enableHiveSupport().getOrCreate()

url = 'jdbc:mysql://172.10.2.70:3306/trancare_spd_q?useSSL=false'
ctx = SQLContext(spark)

df1 = ctx.read.format('jdbc').options(url=url, driver="com.mysql.jdbc.Driver",dbtable="f_local_app_perm_rate_rank",user="trancare",password="trancare").load()
df1.show()

  

posted @ 2020-09-10 17:08  muyue123  阅读(119)  评论(0编辑  收藏  举报