0

在尝试通过启用 pk_chunking = True 来读取 salesforce 中的帐户表时,出现错误

salesforce_bulk.salesforce_bulk.BulkBatchFailed:作业的批次 7511M00000KiqGsQAJ 无失败:无

我查看了 salesforce 监控,其中创建了 11 个批次,pk_chunking除上述情况外,所有批次都有结果,他们的请求看起来像

select Id from Account where Id >='' and Id<'' " 

这是我写的代码:

table_names = ['Account','table1']
bulk = connect_sfdc_bulk('prod')
for x in table_names:
    job = bulk.create_query_job(x, contentType='CSV', pk_chunking=True)
    batch = bulk.query(job, "select Id from %s" % x)
    print(bulk.get_batch_list(job))
    print('batch status: ' , bulk.is_batch_done)
    while not bulk.is_batch_done(batch):
        time.sleep(6)
    for result in bulk.get_all_results_for_query_batch(batch):
        result = unicodecsv.DictReader(result, encoding='utf-8')
    # print(result)
    bulk.close_job(job)

请推荐我如何解决这个错误并从salesforce并行读取大表?

4

1 回答 1

0

我遇到了同样的错误,我如何解决是通过将“job”参数添加到 get_all_results_for_query_batch(batch, Job )

所以代码会是这样的

table_names = ['Account','table1']
bulk = connect_sfdc_bulk('prod')
for x in table_names:
    job = bulk.create_query_job(x, contentType='CSV', pk_chunking=True)
    batch = bulk.query(job, "select Id from %s" % x)
    print(bulk.get_batch_list(job))
    print('batch status: ' , bulk.is_batch_done)
    while not bulk.is_batch_done(batch):
        time.sleep(6)
    for result in bulk.get_all_results_for_query_batch(batch,job):
        result = unicodecsv.DictReader(result, encoding='utf-8')
    # print(result)
    bulk.close_job(job)
于 2019-12-26T13:05:48.673 回答