Data Cloud Python Connector
Use the Data Cloud Python Connector to extract and analyze your Data Cloud data in Python. The connector enables you to:
- Query Data Cloud data using SQL
- Work with data in Pandas DataFrames
- Create visual data models
- Perform analytical operations
- Build machine learning and AI models
Install the connector from PyPI:
After successful installation, you'll see: Successfully Installed salesforce-cdp-connector-<version>
Choose one of two authentication methods:
-
Create a connected app:
- Go to Set up > App Manager > New Connected App
- Complete the basic information
- Enable OAuth settings
- Enter your callback URL
- Select required OAuth scopes
- Save and continue
-
Get your credentials:
- Copy the consumer key (client ID)
- Copy the consumer secret
-
Create a connected app (same steps as Method 1)
-
Select these OAuth scopes:
- refresh_token
- api
- cdp_query_api
- cdp_profile_api
-
Get your OAuth tokens:
- Construct the authorization URL:
- Get the login URL from Set up > My Domain
- Get the callback URL from Set up > App Manager > View Connected App > Call Back URL
- Open the URL in your browser
- Extract the authorization code from the redirect URL
- Make a POST request to get tokens:
- Save the access_token and refresh_token from the response
- Construct the authorization URL:
Create a cursor and execute your SQL query:
Choose one of three methods to retrieve your data:
After setting up the Python connector, here are some recommended next steps:
- Use the connector to query your Data Cloud tables
- Examine the schema of your data model objects
- Try different SQL queries to understand your data structure
- Create Pandas DataFrames for data analysis
- Use Python libraries like matplotlib or seaborn for visualization
- Perform statistical analysis on your data
- Connect the connector to your existing Python applications
- Set up automated data extraction workflows
- Integrate with your data pipeline tools
- Learn about Data Cloud Query API
- Explore Data Cloud data model objects
- Understand Data Cloud limits and guidelines
- Use connection pooling for better performance
- Implement proper error handling
- Follow security best practices for credential management
- Monitor your API usage and stay within limits
- Join the Salesforce Developer Community
- Check out Trailhead modules on Data Cloud
- Explore GitHub examples for Data Cloud integration