'Export data in chunks Python requests

I have data in server database of about 300k rows. I did like to pull this data in chunks to visualize on dashboard however using requests it breaks when exporting. This is the code I used:

import requests
data = {
    'token': 'server token',
    'content': 'record',
    'format': 'csv',
    'type': 'flat',
    'csvDelimiter': '',
    'rawOrLabel': 'raw',
    'rawOrLabelHeaders': 'raw',
    'exportCheckboxLabel': 'false',
    'exportSurveyFields': 'false',
    'exportDataAccessGroups': 'false',
    'returnFormat': 'json'
}
r = requests.post('url',data=data)
print('HTTP Status: ' + str(r.status_code))
print(r.json())

How can I break this into chunks of 2500 each when exporting data from the server?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source