Skip to content

Getting Started

This page gives you one working upsert and one working append against PostgreSQL. The examples use the datasource name pgstyx and assume the JAR is already on the classpath — see Install if not.

Set writeMode=upsert and name the columns that define row identity in mergeKeys. Omitting mergeKeys in upsert mode throws IllegalArgumentException('mergekeys required for upsert mode').

df.write
.format("pgstyx")
.option("url", "jdbc:postgresql://localhost:5432/warehouse")
.option("dbtable", "users")
.option("user", "postgres")
.option("password", "secret")
.option("writeMode", "upsert")
.option("mergeKeys", "user_id")
.save()

url, dbtable, user, and password are required. writeMode defaults to append; it is shown below for clarity.

df.write
.format("pgstyx")
.option("url", "jdbc:postgresql://localhost:5432/warehouse")
.option("dbtable", "events")
.option("user", "postgres")
.option("password", "secret")
.option("writeMode", "append")
.save()

Composite mergeKeys, schemaEvolution beyond strict, validationMode beyond skip, and custom TLS material are paid-plan capabilities. See Pricing when a scenario requires them.