c55d3080cf
CI / test (push) Has been cancelled
CI / verify (push) Has been cancelled
Clients CI / build-server (push) Has been cancelled
Clients CI / test-python (push) Has been cancelled
Clients CI / test-javascript (push) Has been cancelled
Clients CI / test-nim (push) Has been cancelled
Clients CI / test-rust (push) Has been cancelled
Documentation updates: - Fix v0.1.0 → v1.1.0 version numbers in en, ru, fa, zh docs - Add missing Window Functions, Multi-Tenant ERP, Supported Keywords sections to ru, fa, zh baraql.md (~105 lines each) - Expand Turkish and Arabic baraql.md (110 → 268 lines) - Expand Turkish and Arabic installation.md (62 → 307 lines) - Add new Bulgarian documentation files (18 new files) Client updates: - Python: Full async/await rewrite with asyncio, request queueing - Rust: Full async/await rewrite with tokio, async examples - Nim: Update README to v1.1.0 - All clients now support async patterns consistently
BaraDB Python Async Client
Official async Python client for BaraDB — a multimodal database engine written in Nim.
Features
- Async/await — fully non-blocking, concurrent query support
- Binary wire protocol — fast, compact TCP communication
- Request queueing — sequential processing with concurrent execution
- Query builder — fluent SQL construction
- Parameterized queries — safe from SQL injection
- Vector & JSON support — first-class multimodal types
- Context managers — async
async withstatement support
Installation
pip install baradb
Or from source:
git clone https://github.com/katehonz/barabaDB.git
cd clients/python
pip install -e ".[dev]"
Quick Start
import asyncio
from baradb import Client
async def main():
client = Client("localhost", 9472)
await client.connect()
result = await client.query("SELECT name, age FROM users WHERE age > 18")
for row in result:
print(row["name"], row["age"])
await client.close()
asyncio.run(main())
Context Manager
import asyncio
from baradb import Client
async def main():
async with Client("localhost", 9472) as client:
result = await client.query("SELECT 1")
print(result.row_count)
asyncio.run(main())
Parameterized Queries
import asyncio
from baradb import Client, WireValue
async def main():
async with Client("localhost", 9472) as client:
result = await client.query_params(
"SELECT * FROM users WHERE age > $1 AND country = $2",
[WireValue.int64(18), WireValue.string("BG")],
)
for row in result:
print(row)
asyncio.run(main())
Query Builder
import asyncio
from baradb import Client, QueryBuilder
async def main():
async with Client("localhost", 9472) as client:
qb = (
QueryBuilder(client)
.select("name", "email")
.from_("users")
.where("active = true")
.order_by("name")
.limit(10)
)
result = await qb.exec()
for row in result:
print(row)
asyncio.run(main())
Vector Search
import asyncio
from baradb import Client, WireValue
async def main():
async with Client("localhost", 9472) as client:
result = await client.query_params(
"SELECT id, name FROM products ORDER BY embedding <-> $1 LIMIT 5",
[WireValue.vector([0.1, 0.2, 0.3])],
)
print(result.rows)
asyncio.run(main())
Running Tests
Unit tests (no server):
pytest tests/test_wire_protocol.py tests/test_query_builder.py
Integration tests (requires server on localhost:9472):
# Start server
docker run -d -p 9472:9472 barabadb:latest
# Run all tests
pytest
API Reference
Client(host, port, database, username, password, timeout)
| Parameter | Default | Description |
|---|---|---|
host |
localhost |
Server hostname |
port |
9472 |
TCP wire protocol port |
database |
default |
Default database |
username |
admin |
Username |
password |
"" |
Password |
timeout |
30.0 |
Socket timeout in seconds |
Methods (all async)
await client.connect()— open TCP connectionawait client.close()— close connectionawait client.query(sql) -> QueryResult— execute SELECT-like queryawait client.query_params(sql, params) -> QueryResult— parameterized queryawait client.execute(sql) -> int— execute DDL/DML, returns affected rowsawait client.auth(token)— JWT authenticationawait client.ping() -> bool— health check
License
Apache-2.0