Skip to main content

Query and Ingestion Client for Azure using Python

Project description

Getting started

kustopy is a Python SDK for Azure Data Explorer (Kusto).

PyPI version Downloads

Installation and Import

pip install kustopy
from kustopy import KustoPyClient as kpc

Client setup

# Get login credentials from Azure Vault
client_id = dbutils.secrets.get(scope="ce5", key="adxClientId")
client_secret = dbutils.secrets.get(scope="ce5", key="adxClientSecret")
tenant_id = dbutils.secrets.get(scope="ce5", key="adxTenantId")

# Set up the query client
kusto_client = kpc.Client(cluster='https://sample.kusto.windows.net/',
                          database='confidential-satanalytics-sample',
                          client_id=client_id,
                          client_secret=client_secret,
                          tenant_id=tenant_id,
                          truncation=False)

Queries

# Get list of all tables available in database
kusto_client.get_table_names()
# Write kusto queries to get data into pandas dataframe
kusto_client.query_to_df(user_input='SampleTable | take 100 | where fruit=="apple"')

Ingestions

# Drop table from the database
kusto_client.drop_table(tablename='SampleTable')
# Write pandas dataframe to the database. If the table exists you will get an Error.
kusto_client.write_table(dataframe=df, tablename='SampleTable')
# Write pandas dataframe to the database. If the table exists it will be replaced.
kusto_client.write_replace_table(dataframe=df, tablename='SampleTable')

If you want to append data to an existing table, we recommend querying the table to a pandas dataframe using .query_to_df(), doing the transformations within pandas and use .write_replace_table() to overwrite the existing table in the database. This gives you full access to the powerful functions of pandas.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kustopy-1.1.1.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kustopy-1.1.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file kustopy-1.1.1.tar.gz.

File metadata

  • Download URL: kustopy-1.1.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for kustopy-1.1.1.tar.gz
Algorithm Hash digest
SHA256 561c78a0b693a0ab8e8eade79c6ba74b36418995bb01135c44383f8a21c9eceb
MD5 b30f56219706d9b8f388f805912e648d
BLAKE2b-256 662d458ffbf0972dfa1e25c6faa754f552f02eca0d0724f325b4dae7dc60b51b

See more details on using hashes here.

File details

Details for the file kustopy-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: kustopy-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.11

File hashes

Hashes for kustopy-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 58e65a16477ae71b6572d8384bc7451f95e7f275053df4cdb066702386c1e299
MD5 6fcb48eae2ea0127f548580479048d99
BLAKE2b-256 ba09c2dc401500c741bc3f967f7a981e203a25d347164989f00edcb1b55a3af5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page