Kusto数据客户端
项目描述
from azure.kusto.data import KustoClient, KustoConnectionStringBuilder
cluster = "<insert here your cluster name>"
client_id = "<insert here your AAD application id>"
client_secret = "<insert here your AAD application key>"
authority_id = "<insert here your AAD tenant id>"
kcsb = KustoConnectionStringBuilder.with_aad_application_key_authentication(cluster, client_id, client_secret, authority_id)
# It is a good practice to re-use the KustoClient instance, as it maintains a pool of connections to the Kusto service.
# This sample shows how to create a client and close it in the same scope, for demonstration purposes.
with KustoClient(kcsb) as client:
db = "Samples"
query = "StormEvents | take 10"
response = client.execute(db, query)
for row in response.primary_results[0]:
print(row[0], " ", row["EventType"])
Apache Kusto Python 客户端库 提供了使用 Python 查询 Kusto 集群的功能。它与 Python 3.x 兼容,并通过熟悉的 Python DB API 接口支持所有数据类型。
可以使用此库,例如,从 Jupyter Notebooks,这些笔记本连接到 Spark 集群,包括但不限于 Azure Databricks 实例。
异步客户端
Kusto 现在提供用于查询的异步客户端。
要使用客户端,首先使用带有“aio”扩展的包进行安装
pip install azure-kusto-data[aio]
异步客户端使用与常规客户端相同的接口,但它在 azure.kusto.data.aio 命名空间中,并返回 Futures,您需要等待它的结果
from azure.kusto.data import KustoConnectionStringBuilder
from azure.kusto.data.aio import KustoClient
cluster = "<insert here your cluster name>"
client_id = "<insert here your AAD application id>"
client_secret = "<insert here your AAD application key>"
authority_id = "<insert here your AAD tenant id>"
async def sample():
kcsb = KustoConnectionStringBuilder.with_aad_application_key_authentication(cluster, client_id, client_secret, authority_id)
async with KustoClient(kcsb) as client:
db = "Samples"
query = "StormEvents | take 10"
response = await client.execute(db, query)
for row in response.primary_results[0]:
print(row[0], " ", row["EventType"])
链接
项目详情
下载文件
下载适合您平台的应用程序文件。如果您不确定要选择哪一个,请了解更多关于 安装包 的信息。
源代码分发
azure-kusto-data-4.6.1.tar.gz (41.1 kB 查看哈希值)
构建分发
关闭
azure-kusto-data-4.6.1.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | b5f3a76faac58d3ce0e1a7f6ea02b9824d75f3999e8c089a0ef7ad13faf82f44 |
|
MD5 | a15c08dea3a1ee6c96809cbd16ebe770 |
|
BLAKE2b-256 | cd7c1757a26bb8f86a432d9a27cf0de076062d9754d5fbf36b4d51f94437209d |
关闭
azure_kusto_data-4.6.1-py2.py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 4531d45cf8045870dac393cb97d82250efb72f2e54e590b966970184946418ce |
|
MD5 | 345670d582e7d0fdcfeba3f3a9e947ed |
|
BLAKE2b-256 | 633f81fe148345a17d2b9d8cfe89d5ef4ede49b02e93296550965835ae5eb393 |