I have a list of entities in a database which I retrieve and iterate over them like this: import psycopg2 cur.execute("select * from items") rows = cur.fetchall() for x in rows: # some stuff I want to be able to update some of the fields on an entity inside the loop. for x in rows: # some stuff if some_condition: curr.execute("update items set.... Is it possible to do so inside the loop? If not, what's the workaround? Updating them all at once after the loop doesn't work for me. Continue reading...