Skip to main content

KoutenDB Python Driver

Pure Python TCP driver for KoutenDB.

This driver talks to koutend over KoutenDB's high-level wire protocol. It does not reimplement KoutenDB's ring-key, period, head-angle, or placement rules. Applications pass a human-readable ring name, and KoutenDB returns a typed ID.

Status

  • package: PyPI koutendb v0.2.1
  • current mode: native TCP wire driver
  • Python: 3.10+
  • runtime dependencies: none
  • KoutenDB core: running koutend node or cluster

Implemented:

  • persistent TCP connections
  • wire_version / health
  • put / put_codec / put_json / put_nif / put_bif
  • get / get_encoded / get_text / get_json
  • query / query_encoded / query_text / query_json
  • codec metadata negotiation with CODECMETA ON
  • batch_get
  • direct owner redirects from extended FWD ... owner responses
  • routed multi-node batch_get fallback with stable input ordering
  • typed KoutenId
  • one reconnect retry
  • context manager support
  • username/password, shared-secret transport, and TLS authentication

Planned:

  • retrieve / atlas wire APIs once the public wire contract is finalized for drivers
  • ring-read filters/projection once the public wire contract is finalized for drivers
  • connection pooling

Install

Install the published package from PyPI:

python3 -m pip install koutendb

For local driver development, install from a checkout:

python3 -m pip install -e .

Build koutend from the KoutenDB core repository:

git clone https://github.com/puffball1567/koutendb.git
cd koutendb
nimble install -y
nim c -d:release --nimcache:/tmp/nimcache_koutend -o:src/koutend src/koutend.nim

Example

from koutendb import KoutenClient

with KoutenClient.connect("127.0.0.1:17301") as db:
    doc_id = db.put_json(
        "docs/japan/support",
        {"title": "Tokyo support note", "country": "JP"},
        vector=[1.0, 0.0],
    )

    print(db.get_json(doc_id))
    print(db.get_encoded(doc_id).codec)
    print(db.query_json(doc_id, "{ title }"))

Authentication and TLS

connect accepts credentials and TLS options. Password auth and TLS use only the standard library. Shared-secret (secret_key) challenge-response and the encrypted transport it enables additionally need libsodium via PyNaCl — install the secure extra:

pip install koutendb[secure]

Connect over TLS with shared-secret auth, verifying the server against a CA or self-signed certificate PEM (certificate verification stays on):

from koutendb import KoutenClient

db = KoutenClient.connect(
    "127.0.0.1:17301",
    username="alice",
    password="secret",
    secret_key="shared-secret",
    tls_ca_file="/path/to/server.crt",
)

Password-only auth over TLS needs no extra dependency:

db = KoutenClient.connect(
    "127.0.0.1:17301", username="alice", password="secret",
    tls_ca_file="/path/to/server.crt",
)

tls_insecure_skip_verify=True disables certificate verification. The connection is then encrypted but unauthenticated and trivially impersonable, so it is for local smoke tests only — never a production server. Prefer tls_ca_file for self-signed certificates.

Test

From this driver repository, point KOUTENDB_CORE_DIR at a KoutenDB checkout:

KOUTENDB_CORE_DIR=/path/to/koutendb python3 -m unittest discover -s tests

The test starts a two-node local koutend cluster and verifies put/get/query, JSON helpers, codec metadata, BIF opaque payloads, wire_version, and batch_get.

Why A Native Wire Driver?

The Python driver is intended for API services, scripts, experiments, and AI/RAG validation where a running KoutenDB server or cluster is the natural boundary. It keeps Python out of KoutenDB's placement internals and uses the same ring-oriented API that other external drivers should use.

Download files

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

Source Distribution

koutendb-0.2.1.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

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

koutendb-0.2.1-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file koutendb-0.2.1.tar.gz.

File metadata

  • Download URL: koutendb-0.2.1.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for koutendb-0.2.1.tar.gz
Algorithm Hash digest
SHA256 93d3add1b506603b9d8e0f5df2db8d0efa84dc1a401d6e304411afedc4c3a525
MD5 f15fd7e9d399b3ebc4a10dc4ab2ecb79
BLAKE2b-256 87f36a44c5f05c1ea2e5f296c0d8f7b0510994563e109c03f5cb04468240fbe0

See more details on using hashes here.

File details

Details for the file koutendb-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: koutendb-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for koutendb-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4cad1933353fb69aea8c0263876cefaa2962a902eb85eacb75d7de525ae50ea8
MD5 b8796c540d2d690a7b2ed27fa61369c2
BLAKE2b-256 61c29caa2f9008e1d51434df6fda044f4a34dc17fa2fbb996c623d9f892d002a

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 files

0.2.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page