Guest User

Untitled

a guest
Nov 18th, 2018
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. from salesforce_bulk import SalesforceBulk
  2.  
  3. bulk = SalesforceBulk(username=“xxxxxx@xxxx.com", password=“xxxxxxxxx”, security_token=“xxxxxxxxxxxxxxxxxxxxxx”)
  4. # Create a new job
  5. job = bulk.create_query_job("Contact", contentType='JSON')
  6.  
  7. # Add one or more batches to the job
  8. batch = bulk.query(job, "select Id,LastName, LastModifiedDate, SystemModstamp from Contact where SystemModstamp < LAST_N_DAYS:20")
  9.  
  10. # Close the job
  11. bulk.close_job(job)
  12.  
  13. # Wait for each batch to finish
  14. while not bulk.is_batch_done(batch):
  15. time.sleep(10)
  16.  
  17. results = []
  18. for result in bulk.get_all_results_for_query_batch(batch):
  19. results.append(json.load(IteratorBytesIO(result)))
  20.  
  21. for row in results:
  22. print(row)
  23.  
  24. {'attributes': {'type': 'Contact', 'url':
  25. '/services/data/v40.0/sobjects/Contact/0034400001sdfeIaAAI'}, 'Id':
  26. '0034400001sdfeIaAAI', 'LastName': 'obrien', 'LastModifiedDate':
  27. 1539024446000, 'SystemModstamp': 1539024446000}
Add Comment
Please, Sign In to add comment