Thanks Grabriel!
In my opinion the best way would be to insert the data into a temporary table and then perform a MERGE. This ensures that inserting is superfast (due to the fast_executemany in the article) and it ensures that the inserts and updates work because MERGE is atomic.
More information on the merge statement here:
Happy coding!
-mike