BULK remove of DatedConversionRate

I screw up DatedConversionRate data loading with ~2800 records created with incorrect StartDate. As I can retrieve it via SOQL I quickly created some apex script. Something like that

delete [
    FROM DatedConversionRate
    WHERE CreatedDate = TODAY
    AND StartDate < 2018-01-01

and got this

DML operation Delete not allowed on List<DatedConversionRate>

Not cool at all. Also I could not update StartDate with error

DML operation Update not allowed on List<DatedConversionRate>

Okay. Quick googling give me the solution. Here’s solution for create/update and delete DatedConversionRate via SOAP API. So, basically you can do it from Apex

HttpRequest req = new HttpRequest();
req.setEndpoint(URL.getSalesforceBaseUrl().toExternalForm() + '/services/data/v45.0/sobjects/DatedConversionRate/04w0e0000000Po1AAE?_HttpMethod=DELETE');
req.setHeader('Authorization', 'OAuth ' + UserInfo.getSessionId());
req.setHeader('Content-Type', 'application/json');
HttpResponse res = (new Http()).send(req);

But because I had ~2800 records to remove I decided to go with python

import request

record_ids_to_delete = ['04w0e0000000Po1AAE','04w0e0000000Po0AAE','04w0e0000000PnzAAE', ...2800 ids...]
headers = {
    "Authorization": "Bearer AQMAQPJ.ZAiHxG.LUaDqgUabvVdCao77Lq2R2kzcOP0fwMk7lbHA4G7va4U1jRfL_W0hFRBswLYTox2q1yLAsfL93MismKCC",
    "Content-Type": "application/json"
for record_id in record_ids_to_delete:
    url = f'https://my-org-name.my.salesforce.com/services/data/v45.0/sobjects/DatedConversionRate/{record_id}?_HttpMethod=DELETE'
    requests.post(url, headers=headers)

this script might be much more improved for sure. You can add session id generation and use SOQL for retrieving record ids. But I guess this script is just one time thing and copying/pasting session id from browser/any other source as well as quick generation of monstrous array in sublime text are not so big deal when you have to fix it asap.

[python][salesforce][script][soap api]