kapps_triplestore_interface.queries.rdf4j.graph_store#
- kapps_triplestore_interface.queries.rdf4j.graph_store.fetch_statements(self: GraphDB, graph_iri: str | IRI | None = None) Graph | None[source]#
Fetch statements from a named or the default graph.
Queries the RDF4J Graph Store endpoint and parses the response into an rdflib.Graph. When graph_iri is None, the default graph is fetched.
- Parameters:
graph_iri (Optional[GraphNameLike]) – The named graph IRI to fetch; when None, the default graph is fetched.
- Returns:
The parsed graph on success; None when the request fails.
- Return type:
Optional[Graph]
- Raises:
requests.exceptions.RequestException – If the underlying HTTP request fails.
- kapps_triplestore_interface.queries.rdf4j.graph_store.import_statements(self: GraphDB, content: str, overwrite: bool | None = False, graph_iri: str | IRI | None = None, content_type: str | None = 'application/x-turtle') bool[source]#
Import RDF statements into a named or the default graph.
Sends content to the RDF4J Graph Store endpoint using POST (append) or PUT (overwrite). When graph_iri is None, the default graph is targeted.
- Parameters:
content (str) – RDF content to import.
overwrite (Optional[bool]) – Use PUT to overwrite existing content. Defaults to False.
graph_iri (Optional[GraphNameLike]) – Target named graph IRI; default graph when None.
content_type (Optional[str]) – MIME type of content (e.g., ‘application/x-turtle’). Defaults to ‘application/x-turtle’.
- Returns:
True on success (HTTP 204), False otherwise.
- Return type:
- Raises:
requests.exceptions.RequestException – If the underlying HTTP request fails.
- kapps_triplestore_interface.queries.rdf4j.graph_store.clear_graph(self: GraphDB, graph_iri: str | IRI | None = None) bool[source]#
Clear a named graph or the default graph.
Deletes the specified named graph from the triplestore; when graph_iri is None, clears the default graph.
- Parameters:
graph_iri (Optional[GraphNameLike]) – IRI of the named graph to clear; default graph when None.
- Returns:
True on success (HTTP 204), False otherwise.
- Return type:
- Raises:
requests.exceptions.RequestException – If the underlying HTTP request fails.