Connect to IBM Cloud Object Storage Data from HeidiSQL
HeidiSQL is an open-source database administration tool that natively supports MariaDB, MySQL, SQL Server, and PostgreSQL. When paired with CData Connect AI, HediSQL reach extends to include access to live IBM Cloud Object Storage data. This article demonstrates how to connect to IBM Cloud Object Storage using Connect AI and query IBM Cloud Object Storage data in HeidiSQL.
CData Connect AI provides a pure SQL Server interface for IBM Cloud Object Storage, allowing you to query data from IBM Cloud Object Storage without replicating the data to a natively supported database. Using optimized data processing out of the box, CData Connect AI pushes all supported SQL operations (filters, JOINs, etc.) directly to IBM Cloud Object Storage, leveraging server-side processing to return the requested IBM Cloud Object Storage data quickly.
Configure IBM Cloud Object Storage Connectivity for HeidiSQL
Connectivity to IBM Cloud Object Storage from HeidiSQL is made possible through CData Connect AI. To work with IBM Cloud Object Storage data from HeidiSQL, we start by creating and configuring a IBM Cloud Object Storage connection.
- Log into Connect AI, click Sources, and then click Add Connection
- Select "IBM Cloud Object Storage" from the Add Connection panel
-
Enter the necessary authentication properties to connect to IBM Cloud Object Storage.
Register a New Instance of Cloud Object Storage
If you do not already have Cloud Object Storage in your IBM Cloud account, follow the procedure below to install an instance of SQL Query in your account:
- Log in to your IBM Cloud account.
- Navigate to the page, choose a name for your instance and click Create. You will be redirected to the instance of Cloud Object Storage you just created.
Connecting using OAuth Authentication
There are certain connection properties you need to set before you can connect. You can obtain these as follows:
API Key
To connect with IBM Cloud Object Storage, you need an API Key. You can obtain this as follows:
- Log in to your IBM Cloud account.
- Navigate to the Platform API Keys page.
- On the middle-right corner click "Create an IBM Cloud API Key" to create a new API Key.
- In the pop-up window, specify the API Key name and click "Create". Note the API Key as you can never access it again from the dashboard.
Cloud Object Storage CRN
If you have multiple accounts, specify the CloudObjectStorageCRN explicitly. To find the appropriate value, you can:
- Query the Services view. This will list your IBM Cloud Object Storage instances along with the CRN for each.
- Locate the CRN directly in IBM Cloud. To do so, navigate to your IBM Cloud Dashboard. In the Resource List, Under Storage, select your Cloud Object Storage resource to get its CRN.
Connecting to Data
You can now set the following to connect to data:
- InitiateOAuth: Set this to GETANDREFRESH. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken.
- ApiKey: Set this to your API key which was noted during setup.
- CloudObjectStorageCRN (Optional): Set this to the cloud object storage CRN you want to work with. While the connector attempts to retrieve this automatically, specifying this explicitly is recommended if you have more than Cloud Object Storage account.
When you connect, the connector completes the OAuth process.
- Extracts the access token and authenticates requests.
- Saves OAuth values in OAuthSettingsLocation to be persisted across connections.
- Click Save & Test
-
Navigate to the Permissions tab in the Add IBM Cloud Object Storage Connection page and update the User-based permissions.
Add a Personal Access Token
When connecting to Connect AI through the REST API, the OData API, or the Virtual SQL Server, a Personal Access Token (PAT) is used to authenticate the connection to Connect AI. It is best practice to create a separate PAT for each service to maintain granularity of access.
- Click on the Gear icon () at the top right of the Connect AI app to open the settings page.
- On the Settings page, go to the Access Tokens section and click Create PAT.
-
Give the PAT a name and click Create.
- The personal access token is only visible at creation, so be sure to copy it and store it securely for future use.
With the connection configured and a PAT generated, you are ready to connect to IBM Cloud Object Storage data from HeidiSQL.
Connect to IBM Cloud Object Storage from HeidiSQL using Connect AI
To establish a connection from HeidiSQL to the CData Connect AI Virtual SQL Server API, follow these steps.
Create a new HeidiSQL Session
- In the Session Manager, select New in the bottom-left
- Give the new session a descriptive name, e.g. Connect-Cloud-IBM Cloud Object Storage
Configure a SQL Server Connection to Connect AI
- In the session settings, set the Network type to Microsoft SQL Server (TCP/IP)
- The Library DLL should automatically update to MSOLEDBSQL
- Set the Hostname/IP to tds.cdata.com
- Set the User to your CData Connect AI username. This is displayed in the top-right corner of the CData Connect AI interface. For example, [email protected]
- Set the Password to your PAT created in Connect AI in the previous section.
- Set the Port to 14333
Query IBM Cloud Object Storage from HeidiSQL
- In the database listing on the left, find your connection to IBM Cloud Object Storage configured earlier.
- Expand this connection to view individual tables or data objects present within IBM Cloud Object Storage.
- Write custom SQL queries targeting these tables, treating the data source like any SQL Server database, or visually explore each tabular data set by selecting the relevant tables
Get CData Connect AI
To get live data access to hundreds of SaaS, Big Data, and NoSQL sources directly from your SQL Server database, try CData Connect AI today!