Skip to main content

Python client for SutraDB — RDF-star triplestore with native vector indexing

Project description

sutradb

Python client for SutraDB — an RDF-star triplestore with native HNSW vector indexing.

Installation

pip install sutradb

Quick Start

from sutradb import SutraClient

client = SutraClient("http://localhost:3030")

# Check server health
if client.health():
    print("SutraDB is running")

# Run a SPARQL query
results = client.sparql("""
    SELECT ?s ?p ?o WHERE { ?s ?p ?o } LIMIT 10
""")
for binding in results["results"]["bindings"]:
    print(binding["s"]["value"], binding["p"]["value"], binding["o"]["value"])

# Insert triples
client.insert_triples("""
    <http://example.org/paper/1> <http://example.org/title> "Attention Is All You Need" .
    <http://example.org/paper/1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/Paper> .
""")

# Declare a vector predicate
client.declare_vector(
    predicate="http://example.org/hasEmbedding",
    dimensions=1536,
)

# Insert a vector
client.insert_vector(
    predicate="http://example.org/hasEmbedding",
    subject="http://example.org/paper/1",
    vector=[0.23, -0.11, 0.87, ...],  # 1536-dimensional vector
)

# Batch insert vectors
entries = [
    ("http://example.org/paper/1", [0.23, -0.11, ...]),
    ("http://example.org/paper/2", [0.45, 0.02, ...]),
]
result = client.insert_vectors_batch("http://example.org/hasEmbedding", entries)
print(f"Inserted {result['inserted']} vectors")

License

Apache-2.0

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

sutradb-0.4.0.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

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

sutradb-0.4.0-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file sutradb-0.4.0.tar.gz.

File metadata

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

File hashes

Hashes for sutradb-0.4.0.tar.gz
Algorithm Hash digest
SHA256 4a0c322b9304a999b71d17ad31414614cf29d25af705f8413b34b8d11874c297
MD5 9687d0c0048c9dd687e08e85a42b5c95
BLAKE2b-256 6e6ed8da4b16d9bfb4f94851cd40bf2d7d49fcc758edac6fc0c971e0be821c41

See more details on using hashes here.

Provenance

The following attestation bundles were made for sutradb-0.4.0.tar.gz:

Publisher: publish-sdks.yml on EmmaLeonhart/SutraDB

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

File details

Details for the file sutradb-0.4.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for sutradb-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b2cc2762b32ab1ef4a13fd38817e66f10b274822d4a66b7b1fcf077b77b96c4
MD5 de3b4c2fd11f96bce1d71da0a2be7977
BLAKE2b-256 d9f84d71e1c13185deeda3c03f50a9d6447748ca362122f0a6443cf2971570a7

See more details on using hashes here.

Provenance

The following attestation bundles were made for sutradb-0.4.0-py3-none-any.whl:

Publisher: publish-sdks.yml on EmmaLeonhart/SutraDB

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