Skip to content
forked from Azure/pykusto

Query Kusto like a pro from the comfort of your Jupyter notebook

License

Notifications You must be signed in to change notification settings

isabella232/pykusto

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

pykusto is an advanced Python SDK for Azure Data Explorer (a.k.a. Kusto).
Started as a project in the 2019 Microsoft Hackathon.

PyPI version Downloads

Getting Started

Installation

pip install pykusto

Usage

from datetime import timedelta
from pykusto import PyKustoClient, Query

# Connect to cluster with AAD device authentication
# Databases, tables, and columns are auto-retrieved
client = PyKustoClient('https://help.kusto.windows.net')

# Show databases
print(tuple(client.get_databases_names()))

# Show tables in 'Samples' database
print(tuple(client.Samples.get_table_names()))

# Connect to 'StormEvents' table
t = client.Samples.StormEvents

# Build query
(
    Query(t)        
        # Access columns using table variable 
        .project(t.StartTime, t.EndTime, t.EventType, t.Source)
        # Specify new column name using Python keyword argument   
        .extend(Duration=t.EndTime - t.StartTime)
        # Python types are implicitly converted to Kusto types
        .where(t.Duration > timedelta(hours=1))
        .take(5)
        # Output to pandas dataframe
        .to_dataframe()
) 

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

About

Query Kusto like a pro from the comfort of your Jupyter notebook

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%