CSV
serialize_ingest_data(data, fieldnames=None, max_size_bytes=100000000, max_records=150000000)
¶
Serialize data into CSV files for ingestion by Salesforce Bulk API 2.0.
None or missing values are ignored by Salesforce. To set a field in Salesforce to NULL, use the string "#N/A". Relationships are represented as nested dictionaries, with exactly one key-value pair. E.g. {"Account": {"Name": "Acme"}} or {"Custom_Field__r": {"External_Id__c": "123"}.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Iterable[dict[str, Any]]
|
Sequence of dictionaries, each representing a record. |
required |
fieldnames |
Collection[str]
|
Field names, determines order of fields in the CSV file.
By default field names are inferred from the records. This is slow, so
if you know the field names in advance, it is recommended to provide them.
If a record is missing a field, it will be written as an empty string.
If a record has a field not in |
None
|
max_size_bytes |
int
|
Maximum size of each CSV file in bytes. The default of 100MB is recommended by Salesforce recommends. This accounts for base64 encoding increases in size by up to 50%. |
100000000
|
max_records |
int
|
Maximum number of records in each CSV file. By default 150,000,000. This corresponds to the maximum number of records in a 24-hour period. |
150000000
|
Yields:
Type | Description |
---|---|
bytes
|
CSV file as a byte string. |
Source code in src/aiosalesforce/bulk/v2/_csv.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
|
deserialize_ingest_results(data)
¶
Deserialize Salesforce Bulk API 2.0 ingest results from CSV.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
bytes
|
CSV file as a byte string. |
required |
Returns:
Type | Description |
---|---|
list[dict[str, str]]
|
List of records as dictionaries. |