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.3.7.tar.gz (10.6 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.3.7-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for sutradb-0.3.7.tar.gz
Algorithm Hash digest
SHA256 1a7722f0bc8c1b181098112d57ddfede8bf66ef47f6800d93372f3740e5e2244
MD5 372e47279515d2e1cb07e6f2b4caaf1f
BLAKE2b-256 7012fd7719be3a26d655edc63354be6d1dcfa5f62524f034ae0afb6ce35a3aea

See more details on using hashes here.

Provenance

The following attestation bundles were made for sutradb-0.3.7.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.3.7-py3-none-any.whl.

File metadata

  • Download URL: sutradb-0.3.7-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.7

File hashes

Hashes for sutradb-0.3.7-py3-none-any.whl
Algorithm Hash digest
SHA256 4c4425be86d2d38d57c004bf1b57318ec2b54962a8768250351646d8d9d1daee
MD5 91b08bb824c94655cb621fb4dc562eb0
BLAKE2b-256 548c3f5cafac41bdbf7f4074314bb1a411710e2b3d5d034ec6ffe9cf04ee8151

See more details on using hashes here.

Provenance

The following attestation bundles were made for sutradb-0.3.7-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