I am trying to insert the distinct values in my database: My query is like that:
query2 = "INSERT INTO users (id, name, screenName, createdAt, defaultProfile, defaultProfileImage,\
description) SELECT DISTINCT %s, %s, %s, %s, %s, %s, %s;"
cur.execute(query2, (user_id, user_name, user_screenname, user_createdat, \
default_profile, default_profile_image, description))
However, I still get the error: psycopg2.IntegrityError: duplicate key value violates unique constraint "users_key".
I guess that the query is inserting all data and then selects the distinct values? Another way I guess would be to store all data in a temporary database and then retrieve them for there. But is there an easier way?
Thank you!