AttributeError: у объекта 'SQLContext' нет атрибута 'load' - ошибка соединения ApacheSpark + SparkSql с mysql - PullRequest
0 голосов
/ 21 февраля 2019

Я получаю сообщение об ошибке при выполнении кода:

Ошибка:

AttributeError: объект 'SQLContext' не имеет атрибута 'load'

Пожалуйста, дайте мне знать, если кто-то сталкивался с такой же проблемой

Код:

# required import modules
from pyspark import SparkContext, SparkConf
from pyspark.sql import SQLContext
from pyspark.sql.types import *

# creating a configuration for context. here "Spark-SQL" is the name of the application and we will create local spark context.
conf = SparkConf().setAppName("Spark-SQL").setMaster("local")

# create a spark context. It is the entry point into all relational functionality in Spark. 
sc = SparkContext(conf=conf)
sqlContext = SQLContext(sc)



# loading the contents from the MySql database table to the dataframe.
df = sqlContext.load(source="jdbc", url="jdbc:mysql://localhost:3306/test?user=root&password=",dbtable="members_indexed")

# display the schema of the dataframe.
df.show()

# display the schema of the dataframe.
df.printSchema()
...