I have a bunch of pairs of values [(foo1, bar1), (foo2, bar2), ...]
and I want to do a bunch of updates of "set the 'foo' column to 'foo1' where the 'bar' column is 'bar1'".
I am doing this in Python with psycopg2. I could do executemany
with the query UPDATE table SET foo = %s WHERE bar = %s
, but that's a lot of little updates and would take mad long.
How can I do this easily and fast? Perhaps something with a temp table?
Postgres version 9.3.