homework-jianmu/docs/en/08-client-libraries/50-odbc.mdx

76 lines
3.7 KiB
Plaintext

---
sidebar_label: ODBC
title: TDengine ODBC
---
## Introduction
TDengine ODBC driver is a driver specifically designed for TDengine based on the ODBC standard. It can be used by ODBC based applications on Windows to access a local or remote TDengine cluster or TDengine cloud service, like [PowerBI](https://powerbi.microsoft.com).
TDengine ODBC provides two kinds of connections, native connection and WebSocket connection. You can choose to use either one for your convenience, WebSocket is recommded choice and you must use WebSocket if you are trying to access TDengine cloud service.
Note: TDengine ODBC driver can only be run on 64-bit system, and can only be invoked by 64-bit applications.
## Install
1. TDengine ODBC driver supports only Windows platform. To run on Windows, VisualStudio C Runtime library is required. If VisualStudio C Runtime Library is missing on your platform, you can download and install it from [VC Runtime Library](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170).
2. Install TDengine client package for Windows, the version should be above 3.2.1.0, the client package includes both TDengine ODBC driver and some other necessary libraries that will be used in either native connection or WebSocket connection.
## Configure Data Source
### Connection Types
TDengine ODBC driver supports two kinds of connections to TDengine cluster, native connection and WebSocket connection, here is the major differences between them.
1. Only WebSocket can connect to TDengine cloud service.
2. Websocket connection is more compatible with different TDengine server versions, normally you don't need to uupgrade client package with the server side.
3. Native connection normally has better performance, but you need to keep the version aligned with the server side.
4. For most users, it's recommended to use **WebSocket** connection, which has much better compatibility and almost same performance as native connection.
### WebSocket Connection
1. Click the "Start" Menu, and Search for "ODBC", and choose "ODBC Data Source (64-bit)" (Note: Don't choose 32-bit)
2. Select "User DSN" tab, and click "Add" to enter the page for "Create Data Source"
3. Choose the data source to be added, here we choose "TDengine"
4. Click "Finish", and enter the configuration page for "TDengine ODBC Data Source", fill in required fields
![ODBC websocket connection config](./assets/odbc-ws-config-en.webp)
4.1 [DSN]: Data Source Name, required field, to name the new ODBC data source
4.2 [Connection Type]: required field, we choose "WebSocket"
4.3 [URL]: required field, the URL for the ODBC data source, for example, `http://localhost:6041` is the URL for a local TDengine cluster.
4.4 [Database]: optional field, the default database to access
4.5 [User]: optional field, only used for connection testing in step 5; If it's left as blank, "root" user will be used by default.
4.6 [Password]: optional field, only used for connection testing in step 5;
5. Click "Test Connecting" to test whether the data source can be connectted; if successful, it will prompt "connecting success"
6. Click "OK" to sae the configuration and exit.
7. You can also select an already configured data source name in step 2 to change existing configuration.
### Native Connection
Please be noted that native connection can't be used to access a TDengine client service.
The steps are exactly same as "WebSocket" connection, except for you choose "Native" in step 4.2.
## PowerBI
As an example, you can use PowerBI, which inovkes TDengine ODBC driver, to access TDengine, please refer to[Power BI](../../third-party/powerbi) for more details.