1spark = SparkSession.builder.config(conf=spark_conf).getOrCreate()
2
3#make sure the necessary jar files are loaded
4#@ opt/spark/jars folder
5
6df = spark.read \
7 .format("jdbc") \
8 .option("url", "jdbc:postgresql://<host>:<port>/<db_name>") \
9 .option("dbtable", "<schema>.<tablename>") \
10 .option("user", "<username>") \
11 .option("password", "<password>") \
12 .option("driver", "org.postgresql.Driver") \
13 .load()