def _store_inserted_ids_for_batch(self, result_file, local_ids, id_table_name, conn):

    def produce_csv():
        'Iterate over job results and prepare rows for id table'
        reader = unicodecsv.reader(result_file)
        next(reader)
        i = 0
        for (row, local_id) in zip(reader, local_ids):
            if (row[1] == 'true'):
                sf_id = row[0]
                (yield '{},{}\n'.format(local_id, sf_id).encode('utf-8'))
            else:
                self.logger.warning('      Error on row {}: {}'.format(i, row[3]))
            i += 1
    columns = ('id', 'sf_id')
    data_file = IteratorBytesIO(produce_csv())
    self._sql_bulk_insert_from_csv(conn, id_table_name, columns, data_file)
def _store_inserted_ids_for_batch(self, result_file, local_ids, id_table_name, conn):

    def produce_csv():
        'Iterate over job results and prepare rows for id table'
        reader = unicodecsv.reader(result_file)
        next(reader)
        i = 0
        for (row, local_id) in zip(reader, local_ids):
            if (row[1] == 'true'):
                sf_id = row[0]
                (yield '{},{}\n'.format(local_id, sf_id).encode('utf-8'))
            else:
                self.logger.warning('      Error on row {}: {}'.format(i, row[3]))
            i += 1
    columns = ('id', 'sf_id')
    data_file = IteratorBytesIO(produce_csv())
    self._sql_bulk_insert_from_csv(conn, id_table_name, columns, data_file)