Bulk Reference
Salesforce Bulk API 2.0 Client.
This module provides the SfBulk class, a client for interacting with the Salesforce Bulk API 2.0. It facilitates the creation, management, and execution of bulk jobs for queries and DML operations through logically separated 'query' and 'ingest' handlers.
SfBulk
A client for the Salesforce Bulk API 2.0.
This class provides functionalities to execute queries and DML operations
via the Bulk API 2.0. Operations are grouped under the query
and ingest
attributes for logical separation.
ATTRIBUTE | DESCRIPTION |
---|---|
bulk2_url |
The base URL for Bulk API 2.0 endpoints.
TYPE:
|
headers |
The HTTP headers for authentication.
TYPE:
|
query |
Handler for query operations.
TYPE:
|
ingest |
Handler for ingest (CRUD) operations.
TYPE:
|
_interval |
The default waiting interval in seconds.
TYPE:
|
_timeout |
The request timeout in seconds.
TYPE:
|
PARAMETER | DESCRIPTION |
---|---|
sf
|
An authenticated Salesforce client instance.
TYPE:
|
interval
|
The default interval in seconds for waiting job status.
TYPE:
|
timeout
|
The timeout in seconds for API requests.
TYPE:
|
Query
Handle Bulk API 2.0 Query operations.
create
Create a query job.
PARAMETER | DESCRIPTION |
---|---|
query
|
The SOQL query to be executed.
TYPE:
|
include_all
|
If True, the operation is 'queryAll' to include archived and deleted records. Defaults to False.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
SfBulkJobQuery
|
An object to manage the created query job. |
get_info
Get information about a specific query job.
PARAMETER | DESCRIPTION |
---|---|
job_id
|
The ID of the query job.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict[str, Any]
|
A dictionary containing the job's information. |
wait
Wait a query job's status until it completes.
PARAMETER | DESCRIPTION |
---|---|
job_id
|
The ID of the query job to wait.
TYPE:
|
interval
|
The waiting interval in seconds. If None, the default is used.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict[str, Any]
|
The final job information dictionary after completion. |
get_results
Get the results of a completed query job.
PARAMETER | DESCRIPTION |
---|---|
job_id
|
The ID of the query job.
TYPE:
|
format_type
|
The desired output format.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ResultType
|
The query results in the specified format. |
Ingest
Handle Bulk API 2.0 Ingest (CRUD) operations.
create_insert
Create an insert job.
PARAMETER | DESCRIPTION |
---|---|
object_name
|
The Salesforce object API name (e.g., 'Account').
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
SfBulkJob
|
An object to manage the created insert job. |
create_update
Create an update job.
PARAMETER | DESCRIPTION |
---|---|
object_name
|
The Salesforce object API name (e.g., 'Account').
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
SfBulkJob
|
An object to manage the created update job. |
create_upsert
Create an upsert job.
PARAMETER | DESCRIPTION |
---|---|
object_name
|
The Salesforce object API name (e.g., 'Account').
TYPE:
|
external_id_field
|
The API name of the external ID field.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
SfBulkJob
|
An object to manage the created upsert job. |
create_delete
Create a delete job (moves records to the recycle bin).
PARAMETER | DESCRIPTION |
---|---|
object_name
|
The Salesforce object API name (e.g., 'Account').
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
SfBulkJob
|
An object to manage the created delete job. |
create_hard_delete
Create a hard delete job (permanently deletes records).
PARAMETER | DESCRIPTION |
---|---|
object_name
|
The Salesforce object API name (e.g., 'Account').
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
SfBulkJob
|
An object to manage the created hard delete job. |
upload_data
Upload CSV data to a job.
PARAMETER | DESCRIPTION |
---|---|
job_id
|
The ID of the ingest job.
TYPE:
|
csv_data
|
A string containing the data in CSV format.
TYPE:
|
complete_upload
Signal that data upload is complete for a job.
This moves the job from the 'Open' state to the 'UploadComplete' state, making it ready for processing.
PARAMETER | DESCRIPTION |
---|---|
job_id
|
The ID of the ingest job.
TYPE:
|
get_info
Get information about a specific ingest job.
PARAMETER | DESCRIPTION |
---|---|
job_id
|
The ID of the ingest job.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict[str, Any]
|
A dictionary containing the job's information. |
wait
Wait an ingest job's status until it completes.
PARAMETER | DESCRIPTION |
---|---|
job_id
|
The ID of the ingest job to wait.
TYPE:
|
interval
|
The waiting interval in seconds. If None, the default is used.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
dict[str, Any]
|
The final job information dictionary after completion. |
get_successful_results
Get the successful records from a completed ingest job.
PARAMETER | DESCRIPTION |
---|---|
job_id
|
The ID of the ingest job.
TYPE:
|
format_type
|
The desired output format. Defaults to 'dict'.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ResultType
|
The query results in the specified format. |
get_failed_results
Get the failed records from a completed ingest job.
PARAMETER | DESCRIPTION |
---|---|
job_id
|
The ID of the ingest job.
TYPE:
|
format_type
|
The desired output format. Defaults to 'dict'.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ResultType
|
The query results in the specified format. |
get_unprocessed_records
Get unprocessed records from an ingest job.
PARAMETER | DESCRIPTION |
---|---|
job_id
|
The ID of the ingest job.
TYPE:
|
format_type
|
The desired output format. Defaults to 'dict'.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ResultType
|
The query results in the specified format. |