Prerequisites
Before you can configure and use Python with Connect AI, you must have the following:- Python >=3.10
requests>= 2.28.0ijson>= 3.1.0- A data source in your Connect AI account. See Sources for more information.
- A Personal Access Token (PAT). Generate a PAT on the Settings page. Copy this down, as it acts as your password during authentication.
Install the Connector
full extra to enable pandas support.
Connect to Connect AI
The following is an example of Python code connecting to the Connect AI API and performing a query on the Account table in a Salesforce connection. Provide your Connect AI username and password (the password is the PAT you created in the prerequisites).Configuration File
Use a PyHOCON configuration file to keep credentials out of code:Connect to a Workspace
To connect to a Connect AI workspace, add aworkspace parameter as follows:
Examples
Parameterized Queries
Batch Operations
See Data Types for
dataType values and descriptions.Stored Procedures
Pandas Integration
Connection Options
The following table contains the connection options available for the connector.| Parameter | Description | Default |
|---|---|---|
username | Authentication username | - |
password | Personal access token | - |
config_path | Path to PyHOCON config file | - |
workspace | Connect AI workspace name | - |
timeout | HTTP request timeout (seconds) | 90 |
max_retries | Retries on transient 5xx errors | 3 |
retry_delay | Base delay between retries (seconds) | 1.0 |