Skip to main content

holosdb

An RDF 1.2 triplestore with SPARQL 1.2, where access policy is enforced at the index scan rather than by rewriting queries.

pip install holosdb
from holosdb import Store, Principal, Policy

store = Store()                    # in memory
store = Store("./var/db")          # persistent
store.load("data.trig")
store.load("dump.nq.gz")           # gzip: streamed, multi-member safe

for row in store.query("SELECT ?s ?name WHERE { ?s <http://example.com/name> ?name }"):
    print(row["s"], row["name"])

Asking a question as somebody

This is the part no other binding in this ecosystem has. A query can carry a principal and a policy, and the answer comes back filtered to what that principal may see:

policy = (Policy()
          .deny_predicate("http://example.com/salary", except_role="hr")
          .label_graph("http://example.com/reviews", 3))

anyone = Principal.anonymous()
hr     = Principal("urn:user:alice", roles=["hr"], clearance=3)

store.query(q, principal=anyone, policy=policy)   # no salaries, no reviews
store.query(q, principal=hr,     policy=policy)   # both

Because the filtering happens at the scan and not above it:

the answer to Q equals the answer Q would have over the sub-dataset the principal may see.

That holds for every query shape without anyone enumerating them. A COUNT cannot leak the existence of hidden rows, and a FILTER NOT EXISTS cannot probe for them.

Use Policy().fail_closed() when a partial answer would be misread as a complete one — a compliance report, a reconciliation total — and an error is better than a quiet omission.

What else is here

store.update("INSERT DATA { ... }")     # SPARQL Update: all or nothing, policy applies
store.validate("shapes.ttl")            # SHACL: conforms, violations, and each result
store.entail(profile="owl-rl")          # RDFS (the default) or OWL 2 RL, into its own graph,
                                        # with the inconsistencies the OWL RL rules find
store.named_graphs()
store.predicate_counts()                # [(iri, quads), ...]: the store owner's view
store.dictionary_size                   # smaller than you expect: see below
holosdb.geosparql_functions()             # 45 of them
holosdb.has_rocksdb()                     # what this wheel actually contains

Walking the graph

query answers SPARQL. For code that walks a graph pattern by pattern, as code written for an in-memory graph library does, the store reads triple by triple and hands back terms that keep their kind: IRI, BlankNode, Literal (with datatype, language and to_python()) and TripleTerm.

from holosdb import IRI, Literal, DEFAULT_GRAPH

EX = "http://example.com/"
RDF_TYPE = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
store.triples(IRI(EX + "alice"), None, None)   # [(IRI, IRI, Term), ...]; None matches anything
store.objects(EX + "alice", EX + "name")       # [Literal('Alice'), Literal('Alicia', language='es')]
store.subjects(RDF_TYPE, IRI(EX + "Person"))   # distinct, in the order first met
store.value(EX + "alice", EX + "age")          # Literal('30', datatype=xsd:integer), or None
store.items(head)                              # the members of an RDF list
store.triples(predicate=EX + "name", graph=DEFAULT_GRAPH)  # or graph=EX + "g"; None is every graph

An IRI compares and hashes equal to its plain string, so either works as a set member or a dict key; a Literal is equal only to the same literal. A subject or predicate given as a str is an IRI; an object given as a str is a plain literal, as add takes it, so pass an IRI to match an IRI there. principal and policy apply as they do to query.

store.load_text(turtle, format="turtle", base=...) loads RDF held in a str or bytes, as load loads a file. holosdb.prefixes("ontology.ttl") (or prefixes_text(turtle)) gives the prefixes a document declares, which a store does not keep, and store.serialize(prefixes={"ex": EX}) (or dump(..., prefixes=...)) writes them back.

Memory as the store, a file as the backup

An in-memory Store() is the fastest arrangement and needs no directory, and dump makes it a durable one at whatever interval you choose: every graph, as gzipped N-Quads, which load reads back.

store.dump("backup.nq.gz")          # returns the quad count; every named graph kept
store = Store()
store.load("backup.nq.gz")          # the same quads, in the same graphs

The file appears complete or not at all: it is written beside its name and renamed when finished, so a failure part-way leaves an earlier backup at that path as it was. A graph-only format such as Turtle refuses a store with named graphs rather than flattening them. Pass principal= and policy= to write only what that principal may read. Anything written after the last dump is what a crash loses; use Store("./var/db") where that must be nothing.

Queries a program writes

For a query you did not write yourself — an agent's, a user's, a notebook's — the store can bound it and explain it:

store.query(q, timeout=5.0)        # QueryTimeoutError past five seconds
store.query(q, limit=100)          # at most 100 rows; the evaluation stops there
store.query(q, reorder=True)       # plan with statistics over the store
store.explain(q)                   # the plan, with each operator's row count and time

reorder=True is the one to reach for on a large store. It builds statistics once per write — or loads the snapshot a persistent store keeps — and plans each query by them, which for a badly ordered pattern is the difference between milliseconds and minutes. It also lets a DISTINCT, ORDER BY or GROUP BY estimated at over ten million rows be refused at once with QueryRefusedError rather than discovered by the operating system.

Failures come as types you can tell apart without reading the message: SyntaxError, PolicyError, QueryRefusedError and QueryTimeoutError, all of them HolosError.

validate() returns every result, not just a count:

>>> store.validate("shapes.ttl")["results"][0]
{'focus': 'http://example.com/bob', 'path': 'http://example.com/name', 'value': None,
 'severity': 'Violation', 'component': 'http://www.w3.org/ns/shacl#MinCountConstraintComponent',
 'shape': '_:...', 'message': '...'}

There is no memory ceiling here, unlike holos-server: enforcing one needs a counting allocator, and a library does not install one in somebody else's process. A timeout and reorder=True cover the runaway cases a ceiling would.

GeoSPARQL works through the ordinary query path, so it composes with policy — denying geo:asWKT makes a spatial join find nothing:

store.query("""
  PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
  PREFIX uom:  <http://www.opengis.net/def/uom/OGC/1.0/>
  SELECT ?site WHERE {
    ?site <http://www.opengis.net/ont/geosparql#asWKT> ?g .
    FILTER(geof:sfWithin(?g, geof:buffer(?depot, 5, uom:kilometre)))
  }
""")

dictionary_size is reliably smaller than the number of terms — every integer, float, dateTime and short string is packed into its own 64-bit id and never reaches the dictionary. A million triples produced 489,479 dictionary entries.

Threading

A Store is safe to share across threads, and the GIL is released around every query and every load. Concurrent readers genuinely run concurrently rather than taking turns.

What is not here

Persistence is compiled into the wheel rather than installed beside it, so pip install holosdb[rocksdb] is accepted but installs nothing; the published wheels already have it. PACKAGING.md explains why a Python extra cannot do otherwise, and has_rocksdb() reports what you actually got.

Licence

MIT or Apache-2.0, at your option.

Metadata

Release files for holosdb 0.32.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for holosdb 0.32.0
File Size Uploaded Provenance Actions
holosdb-0.32.0.tar.gz 963.1 kB With provenance Details for holosdb-0.32.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for holosdb 0.32.0
File Actions
holosdb-0.32.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details for holosdb-0.32.0-cp311-abi3-win_amd64.whl
holosdb-0.32.0-cp311-abi3-manylinux_2_28_x86_64.whl CPython 3.11 abi3 Linux glibc 2.28+ x86-64 Details for holosdb-0.32.0-cp311-abi3-manylinux_2_28_x86_64.whl
holosdb-0.32.0-cp311-abi3-manylinux_2_28_aarch64.whl CPython 3.11 abi3 Linux glibc 2.28+ ARM64 Details for holosdb-0.32.0-cp311-abi3-manylinux_2_28_aarch64.whl
holosdb-0.32.0-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details for holosdb-0.32.0-cp311-abi3-macosx_11_0_arm64.whl
holosdb-0.32.0-cp311-abi3-macosx_10_13_x86_64.whl CPython 3.11 abi3 macOS 10.13+ x86-64 Details for holosdb-0.32.0-cp311-abi3-macosx_10_13_x86_64.whl

Total release size: 36.9 MB

Release files / holosdb-0.32.0.tar.gz

Download URL holosdb-0.32.0.tar.gz
Size 963.1 kB
Tags Source
SHA-256 checksum
How to use checksums
5c2846c49354b7eed45af4e30ebbdeb3942a4e63fbf74373eaf267e74a66aacd
BLAKE2b-256 checksum
How to use checksums
c096866e4fa5f3a05534fc733d6996550e08d860d7a74001de666c5ca8786a8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

Release files / holosdb-0.32.0-cp311-abi3-win_amd64.whl

Download URL holosdb-0.32.0-cp311-abi3-win_amd64.whl
Size 7.1 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
1bb71a64be2bc1a18066af1374d9699d9bf0803bd8004cef00b2214a476da27f
BLAKE2b-256 checksum
How to use checksums
48b5192bfc9c603ca20e6fdb6aa602628dce4e7eb79fdbbd6b626d6cf18e93b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

Release files / holosdb-0.32.0-cp311-abi3-manylinux_2_28_x86_64.whl

Download URL holosdb-0.32.0-cp311-abi3-manylinux_2_28_x86_64.whl
Size 8.0 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
8b68360ef81486c5899f24d76bf7175bc765dbee7c6b076f335526419df23391
BLAKE2b-256 checksum
How to use checksums
7b54aaeaeb48089d62448172ff51fb70df06044da9e5097841d457af9c9e4d10
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

Release files / holosdb-0.32.0-cp311-abi3-manylinux_2_28_aarch64.whl

Download URL holosdb-0.32.0-cp311-abi3-manylinux_2_28_aarch64.whl
Size 7.4 MB
Tags CPython 3.11 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
2e17bf8716d414b9de24baee4bd7b242ce036279edf3a0782fd447725ca041af
BLAKE2b-256 checksum
How to use checksums
83ee26736d16e37aeb7906af2ecd11991be56f456aeff43baca5f9e6336bdafb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

Release files / holosdb-0.32.0-cp311-abi3-macosx_11_0_arm64.whl

Download URL holosdb-0.32.0-cp311-abi3-macosx_11_0_arm64.whl
Size 6.5 MB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7d7b68f3d9d8bf58095dc9c2daa5528ee37b5b1aa967056bc04d9883f886fb88
BLAKE2b-256 checksum
How to use checksums
10b1eddfd7acbcf2d2826fd3de59d5241500c898d1f3e04824f387107493c1b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

Release files / holosdb-0.32.0-cp311-abi3-macosx_10_13_x86_64.whl

Download URL holosdb-0.32.0-cp311-abi3-macosx_10_13_x86_64.whl
Size 7.0 MB
Tags CPython 3.11 abi3 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
40034c13626228c13130705ec587ad116e14db962ad8136de4ba37a9cc8a1469
BLAKE2b-256 checksum
How to use checksums
0a2e63abd5797901b0dc30e8c528f6b87acfa491c75568404f21c92d27a97201
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

Security for holosdb 0.32.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for holosdb-0.32.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.32.0 This release

6 release files Full provenance

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