Skip to content

Instantly share code, notes, and snippets.

View anthonny's full-sized avatar
🏠
Working from home

Anthonny Quérouil anthonny

🏠
Working from home
View GitHub Profile
@anthonny
anthonny / SparkCopyPostgres.scala
Created August 8, 2017 07:03 — forked from longcao/SparkCopyPostgres.scala
COPY Spark DataFrame rows to PostgreSQL (via JDBC)
import java.io.InputStream
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 = {