kapps_triplestore_interface.queries.triple_single#
- kapps_triplestore_interface.queries.triple_single.triple_exists(self: GraphDB, triple: Tuple[str | IRI | BNode, str | IRI, str | IRI | BNode | Any | Literal], named_graph: str | IRI | None = None) bool[source]#
Check whether a specific triple exists in the graph database.
- Parameters:
triple (TripleLike) – The triple (subject, predicate, object) to check.
named_graph (Optional[GraphNameLike]) – Override the client’s default named graph.
- Returns:
True if the triple exists, False otherwise.
- Return type:
- kapps_triplestore_interface.queries.triple_single.triple_add(self: GraphDB, triple: Tuple[str | IRI | BNode, str | IRI, str | IRI | BNode | Any | Literal], named_graph: str | IRI | None = None) bool[source]#
Add a triple to the graph database.
- Parameters:
triple (TripleLike) – The triple (subject, predicate, object) to insert.
named_graph (Optional[GraphNameLike]) – Override the client’s default named graph.
- Returns:
True if the triple was inserted, False otherwise.
- Return type:
- kapps_triplestore_interface.queries.triple_single.triple_delete(self: GraphDB, triple: Tuple[str | IRI | BNode, str | IRI, str | IRI | BNode | Any | Literal], check_exist: bool | None = True, named_graph: str | IRI | None = None) bool[source]#
Delete a single triple.
A SPARQL DELETE operation in GraphDB can be successful even if the triple does not exist. When check_exist=True, the function verifies the triple is present before attempting deletion.
- Parameters:
triple (TripleLike) – The triple (subject, predicate, object) to delete.
check_exist (Optional[bool]) – Whether to verify existence prior to deletion. Defaults to True.
named_graph (Optional[GraphNameLike]) – Override the client’s default named graph.
- Returns:
True if deletion succeeded (or triple absent when check_exist=False), False otherwise.
- Return type:
- kapps_triplestore_interface.queries.triple_single.triple_update(self: GraphDB, old_triple: Tuple[str | IRI | BNode, str | IRI, str | IRI | BNode | Any | Literal], new_triple: Tuple[str | IRI | BNode | None, str | IRI | None, str | IRI | BNode | Any | Literal | None] | None = None, new_sub: str | IRI | BNode | None = None, new_pred: str | IRI | None = None, new_obj: str | IRI | BNode | Any | Literal | None = None, check_exist: bool | None = True, named_graph: str | IRI | None = None) bool[source]#
Update a triple by replacing any of its parts.
Performs a SPARQL DELETE … INSERT … WHERE that replaces the old triple with a new triple built from provided parts.
- Parameters:
old_triple (TripleLike) – Existing triple to update.
new_triple (Optional[PartialTripleLike]) – Replacement values (subject/predicate/object). Use this or new_sub/new_pred/new_obj.
new_sub (Optional[SubjectLike]) – Replacement subject.
new_pred (Optional[PredicateLike]) – Replacement predicate.
new_obj (Optional[ObjectLike]) – Replacement object.
check_exist (Optional[bool]) – If True, verify that old_triple exists before updating. Defaults to True.
named_graph (Optional[GraphNameLike]) – Override the client’s default named graph.
- Returns:
True if the update succeeded, False otherwise.
- Return type:
- Raises:
InvalidInputError – If neither or both of new_triple and any of new_sub/new_pred/new_obj are provided, or if input triples are incomplete/invalid.