![]() |
VOOZH | about |
The CData ODBC Drivers can be used in any environment that supports loading an ODBC Driver. In this tutorial we will explore using the CData ODBC Driver for Salesforce Data Cloud from within PyCharm. Included are steps for adding the CData ODBC Driver as a data source, as well as basic PyCharm code to query the data source and display results.
To begin, this tutorial will assume that you have already installed the CData ODBC Driver for Salesforce Data Cloud as well as PyCharm.
Follow the steps below to add the pyodbc module to your project.
You can now connect with an ODBC connection string or a DSN. See the Getting Started section in the CData driver documentation for a guide to creating a DSN on your OS.
Salesforce Data Cloud supports authentication via the OAuth standard.
Set to OAuth.
CData provides an embedded OAuth application that simplifies authentication at the desktop.
You can also authenticate from the desktop via a custom OAuth application, which you configure and register at the Salesforce Data Cloud console. For further information, see Creating a Custom OAuth App in the Help documentation.
Before you connect, set these properties:
When you connect, the driver opens Salesforce Data Cloud's OAuth endpoint in your default browser. Log in and grant permissions to the application.
The driver then completes the OAuth process as follows:
For other OAuth methods, including Web Applications and Headless Machines, refer to the Help documentation.
Below is the syntax for a DSN:
[CData SalesforceDataCloud Source] Driver = CData ODBC Driver for Salesforce Data Cloud Description = My Description InitiateOAuth = GETANDREFRESH
Instantiate a Cursor and use the execute method of the Cursor class to execute any SQL statement.
import pyodbc
cnxn = pyodbc.connect('DRIVER={CData ODBC Driver for SalesforceDataCloud};InitiateOAuth = GETANDREFRESH;')
cursor = cnxn.cursor()
cursor.execute("SELECT [Account ID], [Account Name] FROM Account WHERE EmployeeCount = '250'")
rows = cursor.fetchall()
for row in rows:
print(row.[Account ID], row.[Account Name])
After connecting to Salesforce Data Cloud in PyCharm using the CData ODBC Driver, you will be able to build Python apps with access to Salesforce Data Cloud data as if it were a standard database. If you have any questions, comments, or feedback regarding this tutorial, please contact us at [email protected].
Download a free trial of the Salesforce Data Cloud ODBC Driver to get started:
Download NowLearn more:
👁 Salesforce Data Cloud IconThe Salesforce Data Cloud ODBC Driver is a powerful tool that allows you to connect with live data from Salesforce Data Cloud, directly from any applications that support ODBC connectivity.
Access Salesforce Data Cloud data like you would a database - read, write, and update Salesforce Data Cloud 0, etc. through a standard ODBC Driver interface.