Skip to Content
Getting StartedInstall, Auth & Queries

Install and Connect the Python SDK

Beta

The KalamDB Python SDK is not production-ready. It shares the Rust client’s networking and reconnect logic through PyO3, but a 0.8 package is not available on PyPI.

Install the KalamDB Python SDK

For experiments, build from the Python SDK source and match the server version. For production SQL applications, use the HTTP API or the PostgreSQL wire listener with Python psycopg.

Authenticate and query

Create app.tasks using the table guide, then connect with application-user credentials:

python
import asyncioimport osfrom kalamdb import Auth, KalamClient async def main():    async with KalamClient(        "http://localhost:2900",        Auth.basic(os.environ["KALAM_USER"], os.environ["KALAM_PASSWORD"]),    ) as client:        rows = await client.query_rows(            "SELECT * FROM app.tasks WHERE title = $1", ["First task"]        )        print(rows) asyncio.run(main())

Use Auth.jwt(token) when your application already has an accepted JWT. Parameter binding keeps input values separate from SQL. The async context manager closes the client when the block ends.

Upload a FILE value

For a table with a FILE column, query_with_files binds file bytes to the matching placeholder:

python
with open("avatar.png", "rb") as file:    image = file.read()await client.query_with_files(    "INSERT INTO app.profiles (name, avatar) VALUES ($1, FILE('avatar'))",    {"avatar": ("avatar.png", image, "image/png")},    ["Alice"],)

The file example assumes an open client and an existing app.profiles table. Catch KalamAuthError, KalamConnectionError, KalamServerError, or their base KalamError for failures. Do not retry an uncertain write blindly.

Next: Python live queries. Reference: Files.