0
df_chinook = spark.read.format('jdbc').load("/content/datasets/chinook.db")

here is my code I try to load db base into pyspark dataframe, but have (error like this IllegalArgumentException: requirement failed: Option 'url' is required.) what I have to do?

redsiss
  • 23
  • 4

2 Answers2

0

Loading data from a JDBC source

jdbcDF = spark.read \
    .format("jdbc") \
    .option("url", "jdbc:postgresql:dbserver") \
    .option("dbtable", "schema.tablename") \
    .option("user", "username") \
    .option("password", "password") \
    .load()

The JDBC URL of the form jdbc:subprotocol:subname to connect to. The source-specific connection properties may be specified in the URL.

e.g. jdbc:postgresql://localhost/test?user=fred&password=secret

More data-sources examples here

Bubai
  • 1,155
  • 1
  • 10
  • 20
0

Does this answer help you? You could try with

from pyspark.sql import SQLContext

SQLContext.read.jdbc(url="...", table="baz", properties=properties)
rikyeah
  • 1,896
  • 4
  • 11
  • 21