'Insert new events into the event and event_json tables
Args:
txn (twisted.enterprise.adbapi.Connection): db connection
events_and_contexts (list[(EventBase, EventContext)]): events
we are persisting'

def _store_event_txn(self, txn, events_and_contexts):

    if (not events_and_contexts):
        return
    def event_dict(event):
        d = event.get_dict()
        d.pop('redacted', None)
        d.pop('redacted_because', None)
        return d
    self._simple_insert_many_txn(txn, table='event_json', values=[{'event_id': event.event_id, 'room_id': event.room_id, 'internal_metadata': encode_json(event.internal_metadata.get_dict()).decode('UTF-8'), 'json': encode_json(event_dict(event)).decode('UTF-8')} for (event, _) in events_and_contexts])
    self._simple_insert_many_txn(txn, table='events', values=[{'stream_ordering': event.internal_metadata.stream_ordering, 'topological_ordering': event.depth, 'depth': event.depth, 'event_id': event.event_id, 'room_id': event.room_id, 'type': event.type, 'processed': True, 'outlier': event.internal_metadata.is_outlier(), 'content': encode_json(event.content).decode('UTF-8'), 'origin_server_ts': int(event.origin_server_ts), 'received_ts': self._clock.time_msec(), 'sender': event.sender, 'contains_url': (('url' in event.content) and isinstance(event.content['url'], basestring))} for (event, _) in events_and_contexts])
