Skip to main content

CuttleDB Python client — embedded realtime database with vector search, WAL durability, and event streaming. One self-contained binary.

Project description

cuttledb — Python client for CuttleDB

pip install cuttledb
from cuttledb import CuttleDB, ColType

with CuttleDB.connect("127.0.0.1", 7780) as db:
    hid = db.open()
    tid = db.create(hid, "memory", [
        ("text",      ColType.STRING),
        ("embedding", ColType.VEC, 768),
    ])

    db.insert(hid, tid, ["hello world", [0.1] * 768])

    hits = db.knn(hid, tid, col=1, k=5, query=[0.1] * 768)
    for row_id, score in hits:
        print(score, db.get(hid, tid, row_id))

See the full feature set and use cases in the CuttleDB project README.

API surface

Method Returns Notes
CuttleDB.connect(host, port) CuttleDB classmethod, returns connected client; use as context manager
db.open() int new handle id
db.create(hid, name, [(col, type), …]) int new table id
db.insert(hid, tid, values) int new row id
db.insert_batch(hid, tid, rows) list[int] pipelined; bulk-load 1000 rows in <40ms
db.get(hid, tid, row_id) list[str] values returned as strings (no type coercion)
db.count(hid, tid) int O(1)
db.sum / .min / .max(hid, tid, col) float SUM O(1); MIN/MAX SIMD
db.fcount_gt(hid, tid, col, threshold) int SIMD predicate scan
db.select_gt(hid, tid, col, threshold) list[list[str]] all matching rows
db.knn(hid, tid, col, k, query) list[(row_id, score)] cosine, sorted desc
db.delete(hid, tid, row_id) bool swap-with-last
db.save(hid, path) / db.load(path) str / int binary snapshot
db.sub(hid, tid) / db.unsub(hid, tid) str register/cancel push subscription
db.poll_events(timeout) list[Event] drain pending push events
with db.stream_events() as events: … iterator generator-style event loop
db.log(hid, tid, since=0) (cursor, events) per-table change ring buffer
db.ping() / db.hello() / db.info() / db.stats(...) str / dict server meta

All methods raise CuttleDBError on -ERR … responses or protocol violations.

Concurrency model

CuttleDB is thread-compatible but not thread-safe — calls serialize through an internal lock, so multiple threads on one connection won't corrupt the wire protocol, but they will not run in parallel either. For parallel workloads, open one connection per worker. The server is multi-client (thread-per-connection) so this scales.

Subscriptions without a background thread

The Python SDK is intentionally single-threaded. For real-time push:

db.sub(hid, tid)

# blocking loop with a poll interval
while True:
    for evt in db.poll_events(timeout=1.0):
        handle(evt)

Or the generator form:

with db.stream_events(poll_interval=0.1) as events:
    for evt in events:
        handle(evt)

If you need true background push (callbacks fired from a reader thread), wrap poll_events in your own thread — it's three lines.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cuttledb-0.8.0.tar.gz (102.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cuttledb-0.8.0-py3-none-any.whl (28.9 kB view details)

Uploaded Python 3

File details

Details for the file cuttledb-0.8.0.tar.gz.

File metadata

  • Download URL: cuttledb-0.8.0.tar.gz
  • Upload date:
  • Size: 102.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cuttledb-0.8.0.tar.gz
Algorithm Hash digest
SHA256 e8ac3f03b4753f8763bd92fb0b7ee3157ff59ff8c877645a6e877e67e670d079
MD5 2973606bafc0b43e2bc2c2707250a3f3
BLAKE2b-256 219a949284f1545b861820dffa96785f5a45aa5e00bf7c65e6b5d8ef5a39f768

See more details on using hashes here.

Provenance

The following attestation bundles were made for cuttledb-0.8.0.tar.gz:

Publisher: release.yml on mikedconcepcion/CuttleDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cuttledb-0.8.0-py3-none-any.whl.

File metadata

  • Download URL: cuttledb-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 28.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cuttledb-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c894ca4b4fb193ff4e8c91b153760f727a37522ed1a2daaaa5179818089cf230
MD5 b336177889e005ef086571924245407d
BLAKE2b-256 7d1a38d3c33a32c3d12b101f3dab9bb07cae5a116ea2b1609171ec2d3e5577e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for cuttledb-0.8.0-py3-none-any.whl:

Publisher: release.yml on mikedconcepcion/CuttleDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page