Delete duplicate rows with postgresql conditionals

1

My code takes information from the internet and inserts it into the database, however, it inserts the same information more than once a day.

I need to leave only 1 record information per day, that is, each day the program runs, it will only insert the record in the DB.

Example:

    data     |  seller_id  |  
'2017-03-14' |   12345678  |
'2017-03-15' |   12345678  |
    
asked by anonymous 14.03.2017 / 13:16

1 answer

0

Create a unique key on the key that does not want to be repeated, an error occurs if an insert trying to duplicate, handles the error in the application

Example

ALTER TABLE distributors ADD CONSTRAINT dist_id_zipcode_key UNIQUE (dist_id, zipcode);

Source: link

    
14.03.2017 / 13:25