Skip to content

Instantly share code, notes, and snippets.


Anthonny Quérouil anthonny

View GitHub Profile
anthonny / SparkCopyPostgres.scala
Created Aug 8, 2017 — forked from longcao/SparkCopyPostgres.scala
COPY Spark DataFrame rows to PostgreSQL (via JDBC)
View SparkCopyPostgres.scala
import org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils
import org.apache.spark.sql.{ DataFrame, Row }
import org.postgresql.copy.CopyManager
import org.postgresql.core.BaseConnection
val jdbcUrl = s"jdbc:postgresql://..." // db credentials elided
val connectionProperties = {
You can’t perform that action at this time.