Getting error while connecting to MySQL database by using pyspark


#1

Hello,

I am trying to connect to MySQL database in pyspark. But, I am getting “No Suitable Driver” error message. For your reference, I am attaching the screenshot of the code (Green Color) and error message (Yellow Color).

Thanks in advance.


#2

Can someone help with SQL exception while trying accessing MYSql DB from PYSPARK.


#3

Launch pyspark with below command:

pyspark --jars /usr/share/java/mysql-connector-java.jar --master yarn --conf spark.ui.port=12643

and run the below code

mysql = sqlContext.read.format(“jdbc”).
option(“url”, “jdbc:mysql://nn01.itversity.com:3306/retail_db”).
option(“driver”, “com.mysql.jdbc.Driver”).
option(“dbtable”, “orders”).
option(“user”,“retail_dba”).
option(“password”, “itversity”).
load()

mysql.show()