Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Salesforce Bulk Upload API call using python

I am working on the salesforce api and came across the Bulk Upload API. I want to upload some data from a database into salesforce using the Bulk Upload API with python. I am currently using BeatBox as the library. Any pointers on how can I proceed using BeatBox? or are there ways to go about it. I have already done with half of the solution where in the data is queries from SQL and made into csv file. But how do I go about it after this for the BULK upload? Pointers would be of great help.

like image 496
user1746566 Avatar asked Mar 07 '26 21:03

user1746566


1 Answers

Found this package a few days ago:

https://pypi.python.org/pypi/salesforce-bulk/1.0.1

Seems like is what you're looking for:

from salesforce_bulk import CsvDictsAdapter

job = bulk.create_insert_job("Account", contentType='CSV')

accounts = [dict(Name="Account%d" % idx) for idx in xrange(5)]    
csv_iter = CsvDictsAdapter(iter(accounts))    
batch = bulk.post_bulk_batch(job, csv_iter)    
bulk.wait_for_batch(job, batch)    
bulk.close_job(job)    
print "Done. Accounts uploaded."
like image 99
geekymartian Avatar answered Mar 09 '26 10:03

geekymartian