Created
February 3, 2017 08:58
-
-
Save gbraccialli/62a54badf70a311b57ecb30cf80e8f41 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val jdbcDF = spark.read.format("jdbc").options( | |
| Map( | |
| "driver" -> "org.postgresql.Driver", | |
| "url" -> "jdbc:postgresql://localhost/?user=postgres&password=postgres", | |
| "dbtable" -> "nifi_test" | |
| ) | |
| ).load() | |
| jdbcDF.show | |
| case class Test (field1: String, field2: String) | |
| val test = List(Test("B", "xx"), Test("B", "2"), Test("B", "35"), Test("A", "6"), Test("A", "3")) | |
| val rdd = sc.parallelize(test) | |
| val df = rdd.toDF | |
| df.write.format("jdbc").options( | |
| Map( | |
| "driver" -> "org.postgresql.Driver", | |
| "url" -> "jdbc:postgresql://localhost/?user=postgres&password=postgres", | |
| "dbtable" -> "nifi_test" | |
| ) | |
| ).mode("append").save("nifi_test") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment