code: def upsert(self, events):
          
          existing = self.get_existing_keys(events)
          inserts = [e for e in events if not e[self.key] in existing]
          updates = [e for e in events if e[self.key] in existing]
          self.insert(inserts)
          self.update(updates)
docs: Inserts/updates the given events into MySQL