Model Context Protocol (MCP) finally gives AI models a way to access the business data needed to make them really useful at work. CData MCP Servers have the depth and performance to make sure AI has access to all of the answers.
Try them now for free →Using the CData ODBC Driver for Adobe Target in PyCharm
Connect to Adobe Target as an ODBC data source in PyCharm using the CData ODBC Driver for Adobe Target.
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 Adobe Target 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 Adobe Target as well as PyCharm.
Add Pyodbc to the Project
Follow the steps below to add the pyodbc module to your project.
- Click File -> Settings to open the project settings window.
- Click Project Interpreter from the Project: YourProjectName menu.
- To add pyodbc, click the + button and enter pyodbc.
- Click Install Package to install pyodbc.
Connect to Adobe Target
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.
To connect to Adobe Target, you must provide the Tenant property along with OAuth connection properties mentioned below. Note that while other connection properties can influence processing behavior, they do not affect the ability to connect.
To determine your Tenant name:
- Log in to Adobe Experience. The URL will look similar to: "https://experience.adobe.com/#/@mycompanyname/preferences/general-section".
- Extract the value after the "/#/@". In this example, it is "mycompanyname".
- Set the Tenant connection property to that value.
User Accounts (OAuth)
You must set AuthScheme to OAuthClient for all user account flows.
Note: Adobe authentication via OAuth requires updating your token every two weeks.
All Applications
CData provides an embedded OAuth application that simplifies OAuth authentication. Alternatively, you can create a custom OAuth application. Review Creating a Custom OAuth App in the Help documentation for more information.Obtaining the OAuth Access Token
Set the following properties to connect:
- InitiateOAuth: Set to GETANDREFRESH to automatically perform the OAuth exchange and refresh the OAuthAccessToken as needed.
- OAuthClientId : Set to the client Id assigned when you registered your app.
- OAuthClientSecret : Set to the client secret assigned when you registered your app.
- CallbackURL : Set to the redirect URI defined when you registered your app. For example: https://localhost:3333
With these settings, the provider obtains an access token from Adobe Target, which it uses to request data. The OAuth values are stored in the location specified by OAuthSettingsLocation, ensuring they persist across connections.
Below is the syntax for a DSN:
[CData AdobeTarget Source] Driver = CData ODBC Driver for Adobe Target Description = My Description Tenant = mycompanyname
Execute SQL to Adobe Target
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 AdobeTarget};Tenant = mycompanyname;')
cursor = cnxn.cursor()
cursor.execute("SELECT Id, Name FROM Activities WHERE Type = 'AB'")
rows = cursor.fetchall()
for row in rows:
print(row.Id, row.Name)
After connecting to Adobe Target in PyCharm using the CData ODBC Driver, you will be able to build Python apps with access to Adobe Target 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].