In addition to the comments about using placeholders, you should make sure autocommit is off. You might want to do a commit after every 1000 rows or so that you change. You'll need to experiment to see what interval works best.
And check those return values! (Or turn on RaiseError.) You're walking around with your shoes untied.