sfbulk2
raw JSON → 0.8.0 verified Fri May 01 auth: no python maintenance
A utility class for Salesforce Bulk API 2.0, providing features for bulk data operations such as query, insert, update, upsert, and delete. Version 0.8.0 is currently released with no recent updates; the library is in maintenance mode.
pip install sfbulk2 Common errors
error from sfbulk2 import Bulk2 ModuleNotFoundError: No module named 'sfbulk2' ↓
cause The library is not installed or installed in a different environment.
fix
Run
pip install sfbulk2 in your current Python environment. error sfbulk2.exceptions.SFBulk2Error: Invalid username, password, security token; or user locked out. ↓
cause Incorrect Salesforce credentials or missing security token.
fix
Verify your username, password, and security token. If needed, append the security token to the password (e.g., password+token).
error AttributeError: module 'sfbulk2' has no attribute 'Bulk2' ↓
cause Importing the package incorrectly (e.g., `import sfbulk2` then `sfbulk2.Bulk2`).
fix
Use
from sfbulk2 import Bulk2. Warnings
gotcha The library uses OAuth 2.0 with password grant; you must provide username, password, security token, and client credentials. Missing security token is a common issue. ↓
fix Ensure your Salesforce user has a security token (or use an IP-whitelisted network). Append the token to the password if needed.
gotcha Bulk API 2.0 jobs are asynchronous; methods like create_query_job only return a job ID. You must poll for completion using get_query_job_results or similar. ↓
fix Use the provided methods to check job status and retrieve results after the job completes.
deprecated The library has not been updated since 2021 and may not support newer Salesforce Bulk API changes. It is in maintenance mode. ↓
fix Consider migrating to the official Salesforce SDK or other maintained libraries like simple-salesforce.
Imports
- Bulk2 wrong
import sfbulk2correctfrom sfbulk2 import Bulk2
Quickstart
from sfbulk2 import Bulk2
import os
bulk = Bulk2(
username=os.environ.get('SF_USERNAME', ''),
password=os.environ.get('SF_PASSWORD', ''),
security_token=os.environ.get('SF_SECURITY_TOKEN', ''),
client_id=os.environ.get('SF_CLIENT_ID', ''),
client_secret=os.environ.get('SF_CLIENT_SECRET', ''),
domain='login' # or 'test' for sandbox
)
# Example: query records
job_id = bulk.create_query_job('SELECT Id, Name FROM Account')
results = bulk.get_query_job_results(job_id)
print(results)