

def add_many_rows(self, user, data):
    '\n        Shortcut for adding rows in bulk. \n\n        ``data`` must be an array of tuples in the format (data_array, external_id)\n        '
    self.lock()
    try:
        data_typer = DataTyper(self.column_schema)
        solr_rows = [utils.solr.make_data_row(self, d[0], external_id=d[1]) for d in data]
        solr_rows = [data_typer(s, d[0]) for (s, d) in zip(solr_rows, data)]
        solr.add(settings.SOLR_DATA_CORE, solr_rows, commit=True)
        self.schema = data_typer.schema
        if (not self.sample_data):
            self.sample_data = []
        if (len(self.sample_data) < 5):
            needed = (5 - len(self.sample_data))
            self.sample_data.extend([d[0] for d in data[:needed]])
        old_row_count = self.row_count
        self.row_count = self._count_rows()
        added = (self.row_count - (old_row_count or 0))
        updated = (len(data) - added)
        self.last_modified = now()
        self.last_modified_by = user
        if (added and updated):
            self.last_modification = (_('%(added)i rows added and %(updated)i updated') % {
                'added': added,
                'updated': updated,
            })
        elif added:
            self.last_modification = (_('%i rows added') % added)
        else:
            self.last_modification = (_('%i rows updated') % updated)
        self.save()
        return solr_rows
    finally:
        self.unlock()

dataset/ETHPy150Open pandaproject/panda/panda/models/dataset.py Dataset.add_many_rows/original