Skip to main content

Official Python SDK for Altertable Lakehouse API

Project description

Altertable Lakehouse Python SDK

Official Python SDK for the Altertable Lakehouse API.

Installation

pip install altertable-lakehouse

Usage

Initialization

from altertable_lakehouse import Client

client = Client(username="your_username", password="your_password")

# Disable TLS certificate verification for development only
client = Client(username="your_username", password="your_password", verify=False)

Querying

from altertable_lakehouse.models import QueryRequest

# Stream rows (good for large datasets)
req = QueryRequest(statement="SELECT * FROM my_table")
metadata, columns, row_iterator = client.query(req)
print(metadata.values)
print(columns)
for row in row_iterator:
    print(row)

# Accumulate all rows in memory
result = client.query_all(req)
print(result.metadata.values)
print(result.columns)
print(result.rows)

Append

res = client.append(
    catalog="my_cat",
    schema="my_schema",
    table="my_table",
    data={"col1": "val1"},
    sync=False,
)
print(res.ok)

if res.task_id:
    task = client.get_task(res.task_id)
    print(task.status)

Upsert

with open("data.csv", "rb") as f:
    client.upsert(
        catalog="my_cat",
        schema="my_schema",
        table="my_table",
        primary_key="id",
        content=f.read(),
    )

Upload

from altertable_lakehouse.models import UploadMode

with open("data.csv", "rb") as f:
    client.upload(
        catalog="my_cat",
        schema="my_schema",
        table="my_table",
        mode=UploadMode.CREATE,
        content=f,
        content_type="text/csv",
    )

Validate Query

from altertable_lakehouse.models import ValidateRequest

res = client.validate(ValidateRequest(statement="SELECT * FROM non_existent"))
print(res.valid)
print(res.connections_errors)

Query Log & Cancellation

# Get query status
log_res = client.get_query("query_uuid_here")
print(log_res.progress)

# Cancel a query
cancel_res = client.cancel_query("query_uuid_here", "session_id_here")
print(cancel_res.cancelled)

Autocomplete

from altertable_lakehouse.models import AutocompleteRequest

res = client.autocomplete(AutocompleteRequest(statement="SEL", max_suggestions=5))
print(res.statement)
print([suggestion.suggestion for suggestion in res.suggestions])

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

altertable_lakehouse-0.4.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

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

altertable_lakehouse-0.4.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file altertable_lakehouse-0.4.0.tar.gz.

File metadata

  • Download URL: altertable_lakehouse-0.4.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for altertable_lakehouse-0.4.0.tar.gz
Algorithm Hash digest
SHA256 c08674844642c06bb735382b5eebe05793acd8e671524f08b5846213a296eca8
MD5 e8a7d6d5c787d08add7938a1eaa76b05
BLAKE2b-256 d6e8f68e9d73c1a09e37dd7010ecbe6f1c5f6503df83132f6dae2c3846eb9aff

See more details on using hashes here.

Provenance

The following attestation bundles were made for altertable_lakehouse-0.4.0.tar.gz:

Publisher: release-please.yml on altertable-ai/altertable-lakehouse-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file altertable_lakehouse-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for altertable_lakehouse-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 844b962c25fa25ae02032bfa3e65108cadf6ff2e583293aaec72daa36a744013
MD5 e6f17e2b69c2c70f22c9c6730128b6da
BLAKE2b-256 541b25505481013976a93d925dc8597a997c3fe9f32503a30564134e1d607084

See more details on using hashes here.

Provenance

The following attestation bundles were made for altertable_lakehouse-0.4.0-py3-none-any.whl:

Publisher: release-please.yml on altertable-ai/altertable-lakehouse-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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