Right now we're using self.connection directly and not worrying about when to (or not to) commit things to the database. Instead we should be more explicit. Specifically we should create a temp table, do the upsert, and remove the temp table in the same commit.