Inserting Analytic data from Spark to Postgres

后端 未结 4 1975
天涯浪人
天涯浪人 2020-12-30 12:56

I have Cassandra database from which i analyzed the data using SparkSQL through Apache Spark. Now i want to insert those analyzed data into PostgreSQL . Is there any ways to

4条回答
  •  囚心锁ツ
    2020-12-30 13:58

    The answers above refers to old spark versions, in spark 2.* there is jdbc connector, enable write directly to RDBS from a dataFrame.

    example:

    jdbcDF2.write.jdbc("jdbc:postgresql:dbserver", "schema.tablename",
              properties={"user": "username", "password": "password"})
    

    https://spark.apache.org/docs/latest/sql-data-sources-jdbc.html

提交回复
热议问题