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?
CodePudding user response:
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
CodePudding user response:
Does this answer help you? You could try with
from pyspark.sql import SQLContext
SQLContext.read.jdbc(url="...", table="baz", properties=properties)
