sql - Store value from a PostgreSQL record and update by Python -


i want update field of records in rec table instead of doing new insert. use temp table insert records. check if records present in rec table. if yes, want update particular field ("num") adding current value (in temp table) old 1 (in rec). use fetchall() function store values of "num" column (from records in temp , rec).

i run following code collect value of "num" rec , temp , update.

for j in zip(res1, res2):   = list (i)   j = list(j)   j[12]+= i[12]   cursor.execute ("update rec set num = %s ;" % (j[12])) 

in res1 store matched records of temp , in res2 matched records of rec.

however results in nonsense values in field "num" , updated whole records (even didn't match)

have tried using where ?

cursor.execute ("update rec set num = %s num = %s;" % (j[12], j[12]))

it if see more of code. believe there might easier way trying do.


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -