Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 44 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,78 +1,73 @@
# Altertable Lakehouse Python SDK

Official Python SDK for the Altertable Lakehouse API.
You can use this SDK to query and ingest data in Altertable Lakehouse from Python applications.

## Installation
## Install

```bash
pip install altertable-lakehouse
```

## Usage

### Initialization
## Quick start

```python
from altertable_lakehouse import Client
from altertable_lakehouse.models import QueryRequest

client = Client(username="your_username", password="your_password")
metadata, rows = client.query(QueryRequest(statement="SELECT 1 AS ok"))
for row in rows:
print(row)
```

## API reference

### Initialization

`Client(username: str | None = None, password: str | None = None, **options)`

Creates a client authenticated with Basic Auth credentials or token.

### Querying

```python
from altertable_lakehouse.models import QueryRequest
`query(request: QueryRequest)` streams query rows.

# Stream rows (good for large datasets)
req = QueryRequest(statement="SELECT * FROM my_table")
metadata, row_iterator = client.query(req)
for row in row_iterator:
print(row)
`query_all(request: QueryRequest)` returns all rows in memory.

# Accumulate all rows in memory
result = client.query_all(req)
print(result.rows)
```
### Ingestion

### Append
`append(catalog: str, schema: str, table: str, data: dict | list[dict])` appends rows.

```python
res = client.append(catalog="my_cat", schema="my_schema", table="my_table", data={"col1": "val1"})
print(res.ok)
```
`upload(catalog: str, schema: str, table: str, format: UploadFormat, mode: UploadMode, content: bytes)` uploads a file payload.

### Upload
### Query management

```python
from altertable_lakehouse.models import UploadFormat, UploadMode

with open("data.csv", "rb") as f:
client.upload(
catalog="my_cat",
schema="my_schema",
table="my_table",
format=UploadFormat.CSV,
mode=UploadMode.APPEND,
content=f.read()
)
```
`get_query(query_id: str)` returns query status.

### Validate Query
`cancel_query(query_id: str, session_id: str)` cancels a running query.

```python
res = client.validate("SELECT * FROM non_existent")
print(res.valid)
print(res.connections_errors)
```
`validate(statement: str)` validates SQL without execution.

### Query Log & Cancellation
## Configuration

```python
# Get query status
log_res = client.get_query("query_uuid_here")
print(log_res.progress)
| Option | Type | Default | Description |
|---|---|---|---|
| `username` | `str \| None` | `None` | Basic Auth username (or `ALTERTABLE_USERNAME`). |
| `password` | `str \| None` | `None` | Basic Auth password (or `ALTERTABLE_PASSWORD`). |
| `basic_auth_token` | `str \| None` | `None` | Base64 `username:password` token (or env var). |
| `base_url` | `str` | `"https://api.altertable.ai"` | API base URL. |
| `timeout` | `int` | `10` | Request timeout in seconds. |

## Development

Prerequisites: Python 3.9+ and `pip`.

# Cancel a query
cancel_res = client.cancel_query("query_uuid_here", "session_id_here")
print(cancel_res.cancelled)
```bash
pip install -e ".[dev]"
pytest
ruff check .
```

## License

See [LICENSE](LICENSE).
2 changes: 1 addition & 1 deletion specs
Submodule specs updated 33 files
+2 −0 .gitignore
+78 −0 AGENTS.md
+0 −21 HEARTBEAT.md
+19 −22 README.md
+0 −88 SOUL.md
+2 −14 http/SPEC.md
+5 −50 lakehouse/SPEC.md
+0 −0 product-analytics/CONSTANTS.md
+20 −75 product-analytics/SPEC.md
+0 −0 product-analytics/TEST_PLAN.md
+1 −1 product-analytics/fixtures/README.md
+14 −0 product-analytics/fixtures/alias_basic.json
+3 −9 product-analytics/fixtures/identify_basic.json
+7 −11 product-analytics/fixtures/track_basic.json
+20 −0 product-analytics/fixtures/track_null_properties.json
+0 −186 scripts/bootstrap-sdk-repo.sh
+0 −153 skills/bootstrap-sdk/SKILL.md
+0 −20 skills/build-product-analytics-sdk/fixtures/alias_basic.json
+0 −23 skills/build-product-analytics-sdk/fixtures/track_null_properties.json
+0 −143 skills/build-readme/SKILL.md
+0 −98 skills/maintainer-routine/SKILL.md
+0 −156 skills/release-sdk/SKILL.md
+0 −201 skills/review-pr/SKILL.md
+0 −127 skills/sync-repos/SKILL.md
+0 −1 skills/sync-repos/templates/.github/FUNDING.yml
+0 −47 skills/sync-repos/templates/.github/ISSUE_TEMPLATE/bug_report.yml
+0 −21 skills/sync-repos/templates/.github/ISSUE_TEMPLATE/feature_request.yml
+0 −13 skills/sync-repos/templates/.github/PULL_REQUEST_TEMPLATE.md
+0 −83 skills/sync-repos/templates/CODE_OF_CONDUCT.md
+0 −32 skills/sync-repos/templates/CONTRIBUTING.md
+0 −21 skills/sync-repos/templates/LICENSE
+0 −18 skills/sync-repos/templates/SECURITY.md
+0 −179 skills/triage-issues/SKILL.md
Loading