Overwrite data in pyspark

74 views Asked by At

I'm reading data from a postgres table and I'm performing certain operations on it. When I'm trying to update the same data in same table then the whole data gets deleted completely with 0 records. The code using which I'm trying to overwrite is as below

` df.write \

        .format("jdbc") \

        .option("url", "jdbc:postgresql://localhost:5432/demo") \

        .option("user", "postgres") \

        .option("password", "postgres") \

        .option("driver", "org.postgresql.Driver") \

        .option("dbtable", "test_table").mode("overwrite").save()`

Tried append mode but it's appending all the data and it works so there's no connection issue.

0

There are 0 answers