bsfs.triple_store.sparql.sparql module#

class bsfs.triple_store.sparql.sparql.SparqlStore#

Bases: TripleStoreBase

Sparql-based triple store.

The sparql triple store uses a third-party backend (currently rdflib) to store triples and manages them via the Sparql query language.

classmethod Open() SparqlStore#

Return a TripleStoreBase instance connected to uri.

commit()#

Commit the current transaction.

create(node_type: Node, guids: Iterable[URI])#

Create guid nodes with type subject.

exists(node_type: Node, guids: Iterable[URI]) Iterable[URI]#

Return those guids that exist and have type node_type or a subclass thereof.

fetch(node_type: Node, filter: FilterExpression, fetch: FetchExpression) Iterator[Tuple[URI, str, Any]]#

Return (guid, name, value) triples where the guid is determined by the filter query and the name matches the fetch query.

get(node_type: Node, filter: FilterExpression | None = None) Iterator[URI]#

Return guids of nodes of type node_type that match the filter. Return all guids of the respective type if filter is None.

rollback()#

Undo changes since the last commit.

property schema: Schema#

Return the store’s local schema.

set(node_type: Node, guids: Iterable[URI], predicate: Predicate, values: Iterable[Any])#

Add triples to the graph.

It is assumed that all of guids exist and have node_type. This method adds a triple (guid, predicate, value) for every guid in guids and each value in values (cartesian product). Note that values must have length one for unique predicates, and that currently existing values will be overwritten in this case. It also verifies that all symbols are part of the schema and that the predicate matches the node_type. Raises bsfs.errors.ConsistencyError if these assumptions are violated.