[PyGreSQL] How to insert a record if it doesn't exist else update it ?

fdu.xiaojf at gmail.com fdu.xiaojf at gmail.com
Wed Dec 19 10:39:34 EST 2007


Hi all,

What I want to do is:
     if a record already exists in the table, update it
     if a record doesn't exist, insert it into the table

I know that there is a ON DUPLICATE clause with MySQL, so I'm wondering is 
there a corresponding way to do this in PostgreSQL ?

Currently the only way I can find is do query first and then update or insert.

Thanks a lot.

Regards,


More information about the PyGreSQL mailing list