Conecte Spark a Postgres; Conecte Spark a la base de datos

spark = SparkSession.builder.config(conf=spark_conf).getOrCreate()

#make sure the necessary jar files are loaded
#@ opt/spark/jars folder

df = spark.read \
    .format("jdbc") \
    .option("url", "jdbc:postgresql://<host>:<port>/<db_name>") \
    .option("dbtable", "<schema>.<tablename>") \
    .option("user", "<username>") \
    .option("password", "<password>") \
    .option("driver", "org.postgresql.Driver") \
    .load()
sivakguru