I have a dataframe that I wish to write to a database table, however with the command:
df.select("id", "scale", "mentions")\
.write.format("jdbc") \
.option("url", "jdbc:postgresql://ec2xxxxamazonaws.com:xxxx/xxxx") \
.option("dbtable", 'table) \
.option("user", "xxxx") \
.option("password", "xxxx") \
.option("driver", "org.postgresql.Driver").mode('append').save()
I am not able to write to the database because the table already exists since I created it via psql on DB EC2 instance.
My question is, is there a way to create a table, insert queries in the spark python program itself?