'Delete multiple table rows from the PostgreSQL table present in the CSV file

I want to delete multiple table rows that are present in the CSV file

I'm able to make a connection to the db.

conn = psycopg2.connect(host=dbendpoint, port=portinfo, database=databasename, user=dbusername, password=password)
cur = conn.cursor()

I'm able to read the CSV file and store the contents in the dataframe

dfOutput = spark.read.format("text").option("delimiter",",").option("header", "true").option("mode","FAILFAST").option("compression","None").csv(inputFile)

I think I have to convert my dataframe into tuple to use it into psycopg2.

Now I'm unable to proceed forward.

I'm new to psycopg2, so any help would be appreciated.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source