Skip to content

Add Python SDK (PyO3 + maturin)#211

Open
inas-sirhan wants to merge 2 commits intokalamstack:mainfrom
inas-sirhan:feat/python-sdk
Open

Add Python SDK (PyO3 + maturin)#211
inas-sirhan wants to merge 2 commits intokalamstack:mainfrom
inas-sirhan:feat/python-sdk

Conversation

@inas-sirhan
Copy link
Copy Markdown
Collaborator

@inas-sirhan inas-sirhan commented Apr 15, 2026

Adds kalamdb, the official Python SDK for KalamDB. Wraps the existing Rust kalam-client core via PyO3 (FFI), matching the approach used by the Dart SDK. Published as a pip install kalamdb package.

What's included

  • KalamClient with query, query_rows, query_with_files, insert, delete
  • Parameterized queries ($1, $2, …)
  • Live subscriptions via async for event in sub
  • Topic consumers with explicit mark_processed / commit
  • run_agent helper for AI-agent loops (retry + exponential backoff)
  • Auto-refresh of JWT on TOKEN_EXPIRED
  • Lazy login. __init__ does no network I/O; optional connect()
  • async with context managers on Client, Subscription, Consumer
  • Typed exception hierarchy (KalamError, KalamConnectionError, KalamAuthError, KalamServerError, KalamConfigError)
  • Type stubs (.pyi) for editor autocomplete
  • options={"timeout_seconds": ..., "max_retries": ...}
  • README with usage examples
  • GitHub Actions workflow (CI on push/PR, manual-trigger PyPI publish)

Test coverage

61 tests across 13 files, all green against Docker rc2. Covers the full pub/sub loop end-to-end (source table, topic, consume, commit advances offset), file uploads with FILE columns, auto-refresh after token invalidation (including concurrent re-auth), SQL metacharacter handling, and every exception class in the paths that should raise it.

Notes

Please review carefully. Expect more commits, bug fixes, and iteration.

Wraps the existing Rust kalam-client core via PyO3 (FFI), matching the approach used by the Dart SDK. Published as the kalamdb pip package. Includes: KalamClient with query/query_rows/query_with_files/insert/delete; parameterized queries; live subscriptions via async iterator; topic consumers with explicit mark_processed + commit; run_agent helper for AI agent loops (retry + backoff); auto-refresh of JWT on TOKEN_EXPIRED; lazy login (constructor does no network I/O); async context managers on Client/Subscription/Consumer; typed exception hierarchy; type stubs; client options (timeout/retries). Ships with a README and a GitHub Actions workflow that runs tests on Linux/macOS/Windows x Python 3.9-3.12, builds cross-platform wheels, and offers a manually-triggered PyPI publish. 61 tests passing against Docker rc2, covering full pub/sub loop end-to-end, file uploads, auto-refresh (incl. concurrent reauth), and real value/error assertions (not smoke tests).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant