ON CONFLICT DO UPDATE

From: tango ward <tangoward15(at)gmail(dot)com>
To: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: ON CONFLICT DO UPDATE
Date: 2018-05-10 02:04:59
Message-ID: CAA6wQL+Os7BMmowFQqBYLZJdmw6faGn+xbe=OpRa7u7mqC=joQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

Sorry for asking question again.

I would like to know if there's a workaround for this. I need to insert
Student Balance data into a table. The source data have duplicate values
for student_id, school_id and campus_name. My StudentBalance model in Djano
have Class Meta of:

class Meta:
unique_together = (
"school",
"student_id",
"campus_name"
)

Searched online and found this magical tool called ON CONFLICT DO UPDATE. I
played around with it, made it work but there's a problem. The balance data
is not being updated which is because it's not in class Meta with
unique_together. I would like to know if there's a way to update the data
in Student Balance column without adding it to the class Meta?

Thanks,
J

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Chandru Aroor 2018-05-10 02:12:52 Re: New install of 9.5.12 missing default PostgreSQL DB
Previous Message Tim Cross 2018-05-10 00:15:58 Re: issues when installing postgres