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