Using the CData ODBC Driver for HCL Domino in PyCharm



Connect to HCL Domino as an ODBC data source in PyCharm using the CData ODBC Driver for HCL Domino.

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 HCL Domino 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 HCL Domino as well as PyCharm.

Add Pyodbc to the Project

Follow the steps below to add the pyodbc module to your project.

  1. Click File -> Settings to open the project settings window.
  2. Click Project Interpreter from the Project: YourProjectName menu.
  3. To add pyodbc, click the + button and enter pyodbc.
  4. Click Install Package to install pyodbc.

Connect to HCL Domino

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.

Connecting to Domino

To connect to Domino data, set the following properties:

  • URL: The host name or IP of the server hosting the Domino database. Include the port of the server hosting the Domino database. For example: http://sampleserver:1234/
  • DatabaseScope: The name of a scope in the Domino Web UI. The driver exposes forms and views for the schema governed by the specified scope. In the Domino Admin UI, select the Scopes menu in the sidebar. Set this property to the name of an existing scope.

Authenticating with Domino

Domino supports authenticating via login credentials or an Azure Active Directory OAuth application:

Login Credentials

To authenticate with login credentials, set the following properties:

  • AuthScheme: Set this to "OAuthPassword"
  • User: The username of the authenticating Domino user
  • Password: The password associated with the authenticating Domino user

The driver uses the login credentials to automatically perform an OAuth token exchange.

AzureAD

This authentication method uses Azure Active Directory as an IdP to obtain a JWT token. You need to create a custom OAuth application in Azure Active Directory and configure it as an IdP. To do so, follow the instructions in the Help documentation. Then set the following properties:

  • AuthScheme: Set this to "AzureAD"
  • InitiateOAuth: Set this to GETANDREFRESH. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken.
  • OAuthClientId: The Client ID obtained when setting up the custom OAuth application.
  • OAuthClientSecret: The Client secret obtained when setting up the custom OAuth application.
  • CallbackURL: The redirect URI defined when you registered your app. For example: https://localhost:33333
  • AzureTenant: The Microsoft Online tenant being used to access data. Supply either a value in the form companyname.microsoft.com or the tenant ID.

    The tenant ID is the same as the directory ID shown in the Azure Portal's Azure Active Directory > Properties page.

Below is the syntax for a DSN:

[CData Domino Source] Driver = CData ODBC Driver for HCL Domino Description = My Description Server = https://domino.corp.com AuthScheme = OAuthPassword User = my_domino_user Password = my_domino_password

Execute SQL to HCL Domino

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 Domino};Server = https://domino.corp.com;AuthScheme = OAuthPassword;User = my_domino_user;Password = my_domino_password;') cursor = cnxn.cursor() cursor.execute("SELECT Name, Address FROM ByName WHERE City = 'Miami'") rows = cursor.fetchall() for row in rows: print(row.Name, row.Address)

After connecting to HCL Domino in PyCharm using the CData ODBC Driver, you will be able to build Python apps with access to HCL Domino 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].

Ready to get started?

Download a free trial of the HCL Domino ODBC Driver to get started:

 Download Now

Learn more:

HCL Domino Icon HCL Domino ODBC Driver

The HCL Domino ODBC Driver is a powerful tool that allows you to connect with live data from HCL Domino, directly from any applications that support ODBC connectivity.

Access HCL Domino data like you would a database - read, write, and update HCL Domino FALSE, etc. through a standard ODBC Driver interface.