I want to list more than 2000 data from salesforce in python

Asked 2 years ago, Updated 2 years ago, 17 views

Both Python and salesforce are beginners.
Thank you for your cooperation.

I want to list the data retrieved by throwing a query from python to salesforce.
Eventually, I want to do csv output from the list

  • Query Successful
  • If you put the retrieved data (for example, 3000) in the list, you can't store up to 2000 data, and you can't store 1000 data left
  • I think I'm stuck in the upper limit, but I don't know how to do it
  • Python 3.8.1
  • Using simple salesforce

I'll give you the code for groping.

q=a.sf.query("SELECT AccountCode__C, ID FROM Account Limit 3000")  
    cnt=q ['totalSize']    
    with open(csv_dir, 'w', encoding='utf_8') asf:
        writer=csv.writer(f, delimiter='\t', lineterminator='\n')
        val = [[x['AccountCode__c', x['Id']]] for x in q['records']]]    
        for i in range (cnt):
            line=[val[i][0], val[i][1]]
            writer.writerow (line)

python

2022-09-30 18:03

1 Answers

As you advised me, I was able to get all the items in query_all(...) as below.
query_all(...) includes deleted data, so if you want to omit deleted data,
Optional include_deleted=False to exclude it.

q=a.sf.query_all("SELECT AccountCode_C, ID FROM Account Limit 3000", include_deleted=False)


2022-09-30 18:03

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.