您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

将 Qlik Sense 连接到 Azure Cosmos DB 并可视化数据Connect Qlik Sense to Azure Cosmos DB and visualize your data

适用于: SQL API Azure Cosmos DB API for MongoDB

Qlik Sense 是一个数据可视化工具,可将来自不同源的数据合并到单个视图。Qlik Sense is a data visualization tool that combines data from different sources into a single view. Qlik Sense 对数据中每种可能的关系编制了索引,以便可以快速深入了解数据。Qlik Sense indexes every possible relationship in your data so that you can gain immediate insights to the data. 可以使用 Qlik Sense 可视化 Azure Cosmos DB 数据。You can visualize Azure Cosmos DB data by using Qlik Sense. 本文介绍了将 Azure Cosmos DB 连接到 Qlik Sense 并可视化数据所需执行的步骤。This article describes the steps required to connect Azure Cosmos DB to Qlik Sense and visualize your data.

备注

目前仅 SQL API 和 Azure Cosmos DB 的 API for MongoDB 帐户支持将 Qlik Sense 连接到 Azure Cosmos DB。Connecting Qlik Sense to Azure Cosmos DB is currently supported for SQL API and Azure Cosmos DB's API for MongoDB accounts only.

可以将 Qlik Sense 连接到以下 Azure Cosmos DB:You can Connect Qlik Sense to Azure Cosmos DB with:

  • Cosmos DB SQL API,通过使用 ODBC 连接器。Cosmos DB SQL API by using the ODBC connector.

  • Azure Cosmos DB 的 API for MongoDB,通过使用 Qlik Sense MongoDB 连接器(目前提供预览版)。Azure Cosmos DB's API for MongoDB by using the Qlik Sense MongoDB connector (currently in preview).

  • Azure Cosmos DB 的 API for MongoDB 和 SQL API,通过使用 Qlik Sense 中的 REST API 连接器。Azure Cosmos DB's API for MongoDB and SQL API by using REST API connector in Qlik Sense.

  • Cosmos DB Mongo DB API,通过使用 Qlik Core 的 gRPC 连接器。Cosmos DB Mongo DB API by using the gRPC connector for Qlik Core. 本文介绍了使用 ODBC 连接器连接到 Cosmos DB SQL API 的详细信息。This article describes the details of connecting to the Cosmos DB SQL API by using the ODBC connector.

本文介绍了使用 ODBC 连接器连接到 Cosmos DB SQL API 的详细信息。This article describes the details of connecting to the Cosmos DB SQL API by using the ODBC connector.

先决条件Prerequisites

在按照本文中的说明操作之前,请确保以下资源准备就绪:Before following the instructions in this article, ensure that you have the following resources ready:

  • 下载 Qlik Sense 桌面或通过 安装 Qlik Sense 市场项在 Azure 中设置 Qlik Sense。Download the Qlik Sense Desktop or set up Qlik Sense in Azure by Installing the Qlik Sense marketplace item.

  • 下载电子游戏机数据,此示例数据采用 CSV 格式。Download the video game data, this sample data is in CSV format. 将此数据存储在 Cosmos DB 帐户中并在 Qlik Sense 可视化该数据。You will store this data in a Cosmos DB account and visualize it in Qlik Sense.

  • 使用快速入门文章的创建帐户部分所述的步骤创建 Azure Cosmos DB SQL API 帐户。Create an Azure Cosmos DB SQL API account by using the steps described in create an account section of the quickstart article.

  • 创建数据库和集合 – 可以将集合吞吐量值设置为 1000 RU/秒。Create a database and a collection – You can use set the collection throughput value to 1000 RU/s.

  • 将示例电子游戏机销售数据加载到 Cosmos DB 帐户。Load the sample video game sales data to your Cosmos DB account. 可以使用 Azure Cosmos DB 数据迁移工具导入数据,可以执行按顺序批量导入数据。You can import the data by using Azure Cosmos DB data migration tool, you can do a sequential or a bulk import of data. 大约需要 3 到 5 分钟才能将数据导入到 Cosmos DB 帐户。It takes around 3-5 minutes for the data to import to the Cosmos DB account.

  • 使用通过 ODBC 驱动程序连接到 Cosmos DB一文中的步骤下载、安装和配置 ODBC 驱动程序。Download, install, and configure the ODBC driver by using the steps in the connect to Cosmos DB with ODBC driver article. 电子游戏机数据是简单的数据集,无需编辑架构,只需使用默认的集合映射架构。The video game data is a simple data set and you don’t have to edit the schema, just use the default collection-mapping schema.

将 Qlik Sense 连接到 Cosmos DBConnect Qlik Sense to Cosmos DB

  1. 打开 Qlik Sense,然后选择“创建新应用”。Open Qlik Sense and select Create new app. 为应用提供一个名称,然后选择“创建”。Provide a name for your app and select Create.

    创建新的 Qlik Sense 应用

  2. 成功创建新应用后,选择“打开应用”,然后选择“添加来自文件和其他源的数据”。After the new app is created successfully, select Open app and choose Add data from files and other sources.

  3. 从数据源中,选择“ODBC”以打开新的连接设置窗口。From the data sources, select ODBC to open the new connection setup window.

  4. 切换到“用户 DSN”,然后选择之前创建的 ODBC 连接。Switch to User DSN and choose the ODBC connection you created earlier. 为连接提供一个名称,然后选择“创建”。Provide a name for the connection and select Create.

    创建新连接

  5. 创建连接后,可以选择数据库、电子游戏机数据所在的集合,然后进行预览。After you create the connection, you can choose the database, collection where the video game data is located and then preview it.

    选择数据库和集合

  6. 接下来,选择“添加数据”以将数据加载到 Qlik Sense。Next select Add data to load the data to Qlik Sense. 将数据加载到 Qlik Sense 后,可以生成见解并对数据执行分析。After you load data to Qlik Sense, you can generate insights and perform analysis on the data. 可以使用见解,也可以自行生成用来浏览电子游戏机销售的应用。You can either use the insights or build your own app exploring the video games sales. 下图显示The following image shows

    可视化数据

使用 ODBC 连接时的限制Limitations when connecting with ODBC

Cosmos DB 是一个无架构的分布式数据库,其中驱动程序是根据开发人员需要建模的。Cosmos DB is a schema-less distributed database with drivers modeled around developer needs. ODBC 驱动程序需要数据库带有用来推断列、其数据类型和其他属性的架构。The ODBC driver requires a database with schema to infer columns, their data types, and other properties. 由于 SQL API 不是 ANSI SQL,因此具有关系功能的常规 SQL 查询或 DML 语法不适用于 Cosmos DB SQL API。The regular SQL query or the DML syntax with relational capability is not applicable to Cosmos DB SQL API because SQL API is not ANSI SQL. 由于此原因,通过 ODBC 驱动程序发出的 SQL 语句会转换为不具有所有构造的等效项的特定于 Cosmos DB 的 SQL 语法。Due to this reason, the SQL statements issued through the ODBC driver are translated into Cosmos DB-specific SQL syntax that doesn’t have equivalents for all constructs. 若要防止这些转换问题,必须在设置 ODBC 连接时应用架构。To prevent these translation issues, you must apply a schema when setting up the ODBC connection. 通过 ODBC 驱动程序连接一文提供了用来帮助你配置架构的建议和方法。The connect with ODBC driver article gives you suggestions and methods to help you configure the schema. 请确保为 Cosmos DB 帐户内的每个数据库/集合创建此映射。Make sure to create this mapping for every database/collection within the Cosmos DB account.

后续步骤Next Steps

如果使用 Power BI 等不同的可视化工具,则可以使用以下文档中的说明连接到该工具:If you are using a different visualization tool such as Power BI, you can connect to it by using the instructions in the following doc: