code: def upsert_into(self, table):
      
      return SessionContext.session.execute(
          insert(table).from_select(
              self.c,
              self,
          ).on_conflict_do_nothing(),
      ).rowcount
docs: Upsert from a temporarty table into another table.