function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
negannegan 

Bulk Update in Salesforce using python

Hi Everyone,

Need to do a  bulk update in Salesforce. I've found the below code here and plan to use it. Please refer below. 

import csv
from salesforce_bulk import SalesforceBulk
from salesforce_bulk import CsvDictsAdapter

bulk = SalesforceBulk(username=username, password=password)
job = bulk.create_insert_job("bulk_up", contentType='CSV', concurrency='Parallel')
reader = csv.DictReader(open('bulk_up.csv'))
disbursals = []
for row in reader:
    disbursals.append(row)

csv_iter = CsvDictsAdapter(iter(disbursals))
batch = bulk.post_bulk_batch(job, csv_iter)
bulk.wait_for_batch(job, batch)
bulk.close_job(job)
print("Done. Data Uploaded.")

However, upon running it, i encountered an error below. I very new to python so please bare with me. I already installed the salesforce bulk package(pip install salesforce-bulk).
ImportError: cannot import name 'SalesforceBulk'

Also, please advise on where should i save the csv file that i'll be updating in salesforce. Many thanks!
Dave BarkerDave Barker
Hi @negan,

It looks like the salesforce-bulk Python library is only compatible with Python 2.

Try installing it using "pip2 install salesforce-bulk" then run your program using the "python2" command.
Ron Kagan 3Ron Kagan 3

I am running into the same issue with regard to simple_salesforce...

This is true for both Python2 and 3:

https://cl.ly/ab64c3b954d9