Introduction
pykusto is an advanced Python SDK for Azure Data Explorer (a.k.a. Kusto).
Started as a project in the 2019 Microsoft Hackathon.
Getting Started
Installation
Default installation:
pip install pykusto
With dependencies required for running the tests:
pip install pykusto[test]
Without dependencies which are not needed in PySpark:
pip install pykusto --global-option pyspark
Basic 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()
)
Retrying failed queries
# Turn on retrying for all queries
from pykusto import PyKustoClient, RetryConfig, Query
client = PyKustoClient(
"https://help.kusto.windows.net",
retry_config=RetryConfig() # Use default retry config
)
# Override retry config for specific query
Query(client.Samples.StormEvents).take(5).to_dataframe(
retry_config=RetryConfig(attempts=3, sleep_time=1, max_sleep_time=600, sleep_scale=2, jitter=1)
)
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.
Metadata
Release files for pykusto 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pykusto-0.2.0.tar.gz | 56.7 kB | Without provenance | Details for pykusto-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pykusto-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for pykusto-0.2.0-py3-none-any.whl |
Total release size: 96.9 kB
Release files / pykusto-0.2.0.tar.gz
| Download URL | pykusto-0.2.0.tar.gz |
|---|---|
| Size | 56.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e2035b1dc72829d696b2e9acdc85dc7ffe76f8e8d9326b9811f27246b0f6baaa
|
|
BLAKE2b-256 checksum How to use checksums |
8904bbed59d5e6983563707fafe81f889769bd4344d7e4a1af40debdfacd980a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.8.12
|
Release files / pykusto-0.2.0-py3-none-any.whl
| Download URL | pykusto-0.2.0-py3-none-any.whl |
|---|---|
| Size | 40.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fb735ebe03c8155c8427ee85a925d3ac11ce930ea91ab99ab7b7cc9fab929abb
|
|
BLAKE2b-256 checksum How to use checksums |
578be5d22ec2d3371ac243670474d2a3afbb9451723698d53565599e1a51c542
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.8.12
|
Security for pykusto 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.