python无法在salesforce中使用启用了“pk_chunking”的Bulk Api读取表,以创建多个批以检索数据fas

2024-05-19 22:10:46 发布

您现在位置:Python中文网/ 问答频道 /正文

当试图通过启用pk_chunking=True来读取salesforce中的accounts表时,得到的错误为

salesforce_bulk.salesforce_bulk.BulkBatchFailed: Batch 7511M00000KiqGsQAJ of job None failed: None

我查看了salesforce监控,pk_chunking创建了11个批处理,除上述情况外,所有批处理都有结果,它们的请求如下所示

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

下面是我写的代码:

^{pr2}$

请推荐如何修复此错误并并行从salesforce读取大表?在


Tags: ofnoneidtrue错误batchjobbulk
1条回答
网友
1楼 · 发布于 2024-05-19 22:10:46

我也遇到了同样的错误,我的解决方法是通过添加“job”参数来获取\u all_results_for_query_batch(batch,作业

所以代码应该是这样的

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)

相关问题 更多 >