doc: odbc english version

This commit is contained in:
Wade Zhang 2023-12-11 10:58:29 +08:00
parent e117dbdddf
commit e44d26d448
6 changed files with 148 additions and 7 deletions

View File

@ -0,0 +1,75 @@
---
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-zh.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, `https://gw.cloud.taosdata.com?token=your_token` is the URL for a TDengine cloud service.
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.

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

65
docs/en/20-third-party/75-powerbi.md vendored Normal file
View File

@ -0,0 +1,65 @@
---
sidebar_label: Power BI
title: Power BI
description: Use PowerBI and TDengine to analyze time series data
---
## Introduction
With TDengine ODBC driver, PowerBI can access time series data stored in TDengine. You can import tag data, original time series data, or aggregated data into PowerBI from TDengine, to create reports or dashboard without any coding effort.
## Steps
![Power BI use step](./powerbi-step-zh.webp)
### Prerequisites
1. TDengine server has been installed and running well.
2. Power BI Desktop has been installed and running. (If not, please download and install latest Windows X64 version from [PowerBI](https://www.microsoft.com/download/details.aspx?id=58494).
## Install Driver
Depending on your TDengine server version, download appropriate version of TDengine client package from TDengine website [Download Link](https://docs.taosdata.com/get-started/package/), or TDengine explorer if you are using a local TDengine cluster. Install the TDengine client package on same Windows machine where PowerBI is running.
### Configure Data Source
Please refer to [ODBC](../../connector/odbc) to configure TDengine ODBC Driver with WebSocket connection.
### Import Data from TDengine to Power BI
1. Open Power BI and logon, add data source following steps "Home Page" -> "Get Data" -> "Others" -> "ODBC" -> "Connect"
2. Choose data source name, connect to configured data source, go to the nativator, browse tables of the selected database and load data
3. If you want to input some specific SQL, click "Advanced Options", and input your SQL in the open dialogue box and load the data.
To better use Power BI to analyze the data stored in TDengine, you need to understand the concepts of dimention, metric, time serie, correlation, and use your own SQL to import data.
1. Dimention: it's normally category (text) data to describe such information as device, collection point, model. In the supertable template of TDengine, we use tag columns to store the dimention information. You can use SQL like `select distinct tbname, tag1, tag2 from supertable` to get dimentions.
2. Metric: quantitive (numeric) fileds that can be calculated, like SUM, AVERAGE, MINIMUM. If the collecting frequency is 1 second, then there are 31,536,000 records in one year, it will be too low efficient to import so big data into Power BI. In TDengine, you can use data partition query, window partition query, in combination with pseudo columns related to window, to import downsampled data into Power BI. For more details, please refer to [TDengine Specialized Queries](https://docs.taosdata.com/taos-sql/distinguished/)。
- Window partition query: for example, thermal meters collect one data per second, but you need to query the average temperature every 10 minutes, you can use window subclause to get the downsampling data you need. The corresponding SQL is like `select tbname, _wstart dateavg(temperature) temp from table interval(10m)`, in which _wstart is a pseudo column indicting the start time of a widow, 10m is the duration of the window, `avg(temperature)` indicates the aggregate value inside a window.
- Data partition query: If you want to get the aggregate value of a lot of thermal meters, you can first partition the data and then perform a series of calculation in the partitioned data spaces. The SQL you need to use is `partition by part_list`. The most common of data partition usage is that when querying a supertable, you can partition data by subtable according to tags to form the data of each subtable into a single time serie to facilitate analytical processing of time series data.
3. Time Serie: When curve plotting or aggregating data based on time lines, date is normally required. Data or time can be imported from Excel, or retrieved from TDengine using SQL statement like `select _wstart date, count(*) cnt from test.meters where ts between A and B interval(1d) fill(0)`, in which the fill() subclause indicates the fill mode when there is data missing, pseudo column _wstart indicates the date to retrieve.
4. Correlation: Indicates how to correlate data. Dimentions and Metrics can be correlated by tbname, dates and metrics can be correlated by date. All these can cooperate to form visual reports.
### Example - Meters
TDengine has its own specific data model, which uses supertable as template and creates a specific table for each device. Each table can have maximum 4,096 data columns and 128 tags. In the example of meters, assume each meter generates one record per second, then there will be 86,400 records each day and 31,536,000 records every year, then only 1,000 meters will occupy 500GB disk space. So, the common usage of Power BI should be mapping tags to dimention columns, mapping the aggregation of data columns to metric columns, to provide indicators for decision makers.
1. Import Dimentions
Import the tags of tables in PowerBI, and name as "tags", the SQL is like `select distinct tbname, groupid, location from test.meters;`.
2. Import Metrics
In Power BI, import the average current, average voltage, average phase with 1 hour window, and name it as "data", the SQL is like `select tbname, _wstart ws, avg(current), avg(voltage), avg(phase) from test.meters PARTITION by tbname interval(1h)` .
3. Correlate Dimentions and Metrics
In Power BI, open model view, correlate "tags" and "data", and set "tabname" as the correlation column, then you can use the data in histogram, pie chart, etc. For more information about building visual reports in PowerBI, please refer to [Power BI](https://learn.microsoft.com/power-bi/)。

View File

@ -4,7 +4,7 @@ title: TDengine ODBC
--- ---
##简介 ## 简介
TDengine ODBC 是为 TDengine 实现的 ODBC 驱动程序,支持 Windows 系统的应用(如 [PowerBI](https://powerbi.microsoft.com/zh-cn/) 等)通过 ODBC 标准接口访问本地、远程和云服务的 TDengine 数据库。 TDengine ODBC 是为 TDengine 实现的 ODBC 驱动程序,支持 Windows 系统的应用(如 [PowerBI](https://powerbi.microsoft.com/zh-cn/) 等)通过 ODBC 标准接口访问本地、远程和云服务的 TDengine 数据库。
@ -14,15 +14,15 @@ TDengine ODBC 提供基于 WebSocket推荐和 原生连接两种方式连
想更多了解 TDengine 时序时序数据库的使用,可访问 [TDengine官方文档](https://docs.taosdata.com/intro/)。 想更多了解 TDengine 时序时序数据库的使用,可访问 [TDengine官方文档](https://docs.taosdata.com/intro/)。
##安装 ## 安装
1. 仅支持 Windows 平台。Windows 上需要安装过 VC 运行时库,可在此下载安装 [VC运行时库](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170) 如果已经安装VS开发工具可忽略。 1. 仅支持 Windows 平台。Windows 上需要安装过 VC 运行时库,可在此下载安装 [VC运行时库](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170) 如果已经安装VS开发工具可忽略。
2. 安装 TDengine Windows 客户端,版本在 3.2.1.0 或以上,都会包含 TDengine 的 ODBC 驱动。 2. 安装 TDengine Windows 客户端,版本在 3.2.1.0 或以上,都会包含 TDengine 的 ODBC 驱动。
##配置数据源 ## 配置数据源
###数据源连接类型与区别 ### 数据源连接类型与区别
TDengine ODBC 支持两种连接 TDengine 数据库方式Websocket 连接与 Native 连接,其区别如下: TDengine ODBC 支持两种连接 TDengine 数据库方式Websocket 连接与 Native 连接,其区别如下:
@ -34,7 +34,7 @@ TDengine ODBC 支持两种连接 TDengine 数据库方式Websocket 连接与
4. 对于一般用户,建议使用 **Websocket** 连接方式,性能与 Native 差别不大,兼容性更好。 4. 对于一般用户,建议使用 **Websocket** 连接方式,性能与 Native 差别不大,兼容性更好。
###WebSocket 连接 ### WebSocket 连接
1. 【开始】菜单搜索打开【ODBC 数据源(64 位)】管理工具注意不要选择ODBC 数据源(32 位) 1. 【开始】菜单搜索打开【ODBC 数据源(64 位)】管理工具注意不要选择ODBC 数据源(32 位)
@ -64,7 +64,7 @@ TDengine ODBC 支持两种连接 TDengine 数据库方式Websocket 连接与
7. 也可以在第2步选择已经配置好的数据源名通过【配置】按钮进入配置页面修改已有配置 7. 也可以在第2步选择已经配置好的数据源名通过【配置】按钮进入配置页面修改已有配置
###原生连接(不支持云服务) ### 原生连接(不支持云服务)
1. 【开始】菜单搜索打开【ODBC 数据源(64 位)】管理工具注意不要选择ODBC 数据源(32 位) 1. 【开始】菜单搜索打开【ODBC 数据源(64 位)】管理工具注意不要选择ODBC 数据源(32 位)
@ -94,5 +94,6 @@ TDengine ODBC 支持两种连接 TDengine 数据库方式Websocket 连接与
7. 也可以在第2步选择已经配置好的数据源名通过【配置】按钮进入配置页面修改已有配置 7. 也可以在第2步选择已经配置好的数据源名通过【配置】按钮进入配置页面修改已有配置
## 与第三方集成
使用Power BI 与 TDengine 分析时序数据请参考 [Power BI](../../third-party/powerbi) 作为使用 TDengine ODBC driver 的一个示例,你可以使用 Power BI 与 TDengine 分析时序数据。更多细节请参考 [Power BI](../../third-party/powerbi)