Python SDK¶
Python client for HeliosDB-Lite server.
Installation¶
Quick Start¶
from heliosdb_lite import Client
# Connect to server
client = Client("http://localhost:8080")
# Execute query
result = await client.query("SELECT * FROM users")
for row in result.rows:
print(row)
# Close connection
await client.close()
Async Client¶
import asyncio
from heliosdb_lite import Client
async def main():
client = Client(
base_url="http://localhost:8080",
api_key="your-api-key",
branch="main",
timeout=30.0
)
# Query
result = await client.query(
"SELECT * FROM users WHERE id = $1",
params=[1]
)
# Execute (returns rows affected)
count = await client.execute(
"UPDATE users SET name = $1 WHERE id = $2",
params=["Alice", 1]
)
await client.close()
asyncio.run(main())
Vector Search¶
results = await client.vector_search(
store="documents",
query="machine learning",
top_k=10,
min_score=0.5,
filter={"category": "tech"}
)
for result in results:
print(f"{result.id}: {result.score} - {result.content}")
Branching¶
# Create branch
await client.create_branch("dev", from_branch="main")
# Switch branch
client.branch = "dev"
# Merge
await client.merge_branch("dev", "main")
Natural Language Query¶
result, sql = await client.nl_query("How many orders last week?")
print(f"SQL: {sql}")
print(f"Result: {result.rows}")
See API Reference for complete documentation.