while trying to read the accounts table in salesforce by enabling the pk_chunking = True , getting an error as
salesforce_bulk.salesforce_bulk.BulkBatchFailed: Batch 7511M00000KiqGsQAJ of job None failed: None
I looked at the salesforce monitoring and there are 11 batches created by the pk_chunking
and all the batches except the above case have the results and their requests look like
select Id from Account where Id >='' and Id<'' "
Here is the code I wrote:
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)
Please recommend how can I fix this error and read the large tables from salesforce with batches in parallel?