將dataframe寫入到kusto table

官方非常confused的API https://github.com/Azure/azure-kusto-python/blob/master/azure-kusto-ingest/tests/sample.py

data = pd.DataFrame(data=[['zz',1],['b', 2]], columns=['name', 'age'])
cluster = "https://ingest-<cluster_name>.kusto.windows.net"
ingestion_props = IngestionProperties(database="cluster_name", table="table_name", dataFormat=DataFormat.csv)
kscb = KustoConnectionStringBuilder.with_aad_application_key_authentication(
        cluster, configkey.client_id, configkey.client_secret, configkey.authority_id)
client = KustoIngestClient(kscb)
client.ingest_from_dataframe(data, ingestion_properties=ingestion_props)

主要注意:
1.如果要把數據寫到cluster_name中, cluster link中cluste_name前要加ingest-
2. dataFormat=DataFormat.csv 中的csv是小寫,API上大寫有錯

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章