0
from simple_salesforce import Salesforce
import pandas as pd

# username = 'USER_NAME'
# password = 'PASSWORD'
# security_token = 'SECURITY_TOKEN'

uname = 'USER_NAME'
passwd = 'PASSWORD'
token = 'SECURITY_TOKEN'

sfdc_query = Salesforce(username = uname,password=passwd,security_token=token)

object_list = []
for x in sfdc_query.describe()["sobjects"]:
    object_list.append(x["name"])

object_list = ['ag1__c'] # my custom database in sales force
obj = ", ".join(object_list)

soql = 'SELECT FIELDS(CUSTOM) FROM ag1__c LIMIT 200' # CUSTOM
sfdc_rec = sfdc_query.query_all(soql)
sfdc_df = pd.DataFrame(sfdc_rec['records'])
sfdc_df

Here i am trying to get all the records from my custom database in sales force which has 1044 rows and i want to extract all the records. i have tried lot of things but its not working please help me out with this, it will be great help to me. thanks

ERROR: -

SalesforceMalformedRequest: Malformed request https://pujatiles-dev-ed.develop.my.salesforce.com/services/data/v52.0/query/?q=SELECT+FIELDS%28CUSTOM%29+FROM+ag1__c. Response content: [{'message': 'The SOQL FIELDS function must have a LIMIT of at most 200', 'errorCode': 'MALFORMED_QUERY'}]
Rahulrvz
  • 9
  • 3

1 Answers1

0

If you need more rows - you need to list all the fields you need, explicitly mention them in SELECT. "FIELDS(ALL)" trick is limited to 200 records, period. If you don't know what fields are there - simple should have a "describe" operation for you. And then the query has to be under 100K characters.

As for "size in MB" - you can't query that. You can fetch record counts per table (it's a special call, not a query: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_record_count.htm)

And then... For most objects it's count * 2kB. There are few exceptions (CampaignMember uses 3kB; Email Message uses however many kilobytes the actual email had) but that's a good rule of thumb.

https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_limits.htm is interesting too, DataStorageMB and FileStorageMB.

eyescream
  • 18,088
  • 2
  • 34
  • 46