Python SDK quick reference for agents
Baseline: ekodb-client 0.37.0, imported as ekodb_client. Install with python -m pip install ekodb-client==0.37.0. Checked against the Python binding, query builder and CRUD example.
Runnable Examples (Check Before Guessing)
Before writing SDK code, consult the matching runnable example below for exact imports, method signatures and error handling. These links follow the SDK's main branch; compare them with the version installed in your application. Follow the language directory's run instructions and use a disposable deployment when executing examples that write data.
| Task | Runnable example |
|---|---|
| CRUD | client_simple_crud.py |
| QueryBuilder | client_query_builder.py |
| Joins | client_joins.py |
| Schemas | client_schema.py |
| TTL | client_document_ttl.py |
| Transactions | client_transactions.py |
| Stored Functions | client_functions.py |
| Concurrency / Locks / RateLimits | client_concurrency_stages.py |
| Chat / RAG | client_chat_basic.py, rag_conversation_system.py |
| Search | client_search.py |
| WebSockets | client_websocket_subscribe.py |
| Admin / Permissions | client_admin.py |
Initialize and query
The application supplies runtime credentials. Client.new constructs the client synchronously; network operations are awaited:
from ekodb_client import Client, QueryBuilder, extract_record
async def list_active(base_url: str, api_key: str):
client = Client.new(base_url, api_key)
query = QueryBuilder().eq("active", True).limit(25).build()
records = await client.find("agent_tasks", query)
return [extract_record(record) for record in records]
The Rust-backed binding handles token exchange and refresh. Run the coroutine within the application's async lifecycle. Do not add await to Client.new or invent an init() requirement.
Method map
| Task | Call shape |
|---|---|
| Insert | await client.insert(collection, record) |
| Find | await client.find(collection, query_dict) |
| Point read | await client.find_by_id(collection, id) |
| Merge update | await client.update(collection, id, fields) |
| Delete | await client.delete(collection, id) |
| Batch insert | await client.batch_insert(collection, records) |
| Read / change schema | get_schema(collection) / update_schema_constraints(collection, constraints) |
| Save / call a function | save_user_function(definition) / call_function(id_or_label, params) |
| Transactions | begin_transaction(isolation_level=None), commit_transaction(id), rollback_transaction(id) |
All network calls in the table are async. Optional keywords use snake_case, including transaction_id, bypass_ripple, select_fields and exclude_fields, where supported by the method. find takes a query dictionary: keep filter, sort, limit and skip in that dictionary. The older separate limit= argument is deprecated; do not mix it with a query dict.
Values, TTL and failures
- Records are dictionaries; query results are lists of dictionaries. Write
dict,listandboolvalues directly for native objects, arrays and booleans. - A response field can be a typed envelope. Use
get_value(record["field"]),get_object_value,get_array_valueorextract_record; the returned ID is an opaque string. - Record
ttlbelongs in the insert/update dictionary or each batch-insert record. Omitting it on update preserves expiry. Insert may return onlyid; use a point read if the stored fields are needed. call_functionreturns a dictionary withrecordsand metadata.Countreplaces the working set, so readresult["records"][0]["count"]for an output namedcount.- Preserve exceptions. Version 0.37.0 exposes transaction status in errors such as
Transaction error (409)and does not automatically retry commit operations. Retry a complete transaction only after classifying the failure. Never use a broadexceptto turn errors into empty lists.
Read canonical semantics before choosing a type, paging strategy or retry policy. The versioned examples directory covers joins, functions, schemas, TTL and transactions.