Import API¶
Module: ontosql.import_ (trailing underscore — import is a Python keyword).
Errors¶
ontosql.import_.hydrate.OntoImportError ¶
Bases: Exception
Raised when RDF cannot be mapped to a semantic instance.
Hydration¶
ontosql.import_.hydrate.graph_to_instance ¶
graph_to_instance(graph: Store, mapper: type[Any], *, iri: str | None = None, registry: PrefixRegistry | None = None, max_nesting_depth: int = DEFAULT_MAX_NESTING_DEPTH, _depth: int = 0, _visited: set[str] | None = None) -> OntoModel
Hydrate a semantic instance from triples using mapper metadata.
ontosql.import_.hydrate.subject_iri_from_jsonld ¶
Extract @id from a JSON-LD document.
Parsing¶
ontosql.import_.parse.load_graph ¶
load_graph(data: str | bytes, *, format: str = 'turtle', registry: PrefixRegistry | None = None, max_bytes: int | None = None, max_triples: int | None = None, untrusted: bool = False) -> Store
Parse RDF text into a Store.
Optional max_bytes and max_triples guard untrusted payloads (raises
OntoImportError when exceeded).
When untrusted=True, applies UNTRUSTED_DEFAULT_MAX_BYTES and
UNTRUSTED_DEFAULT_MAX_TRIPLES for any limit not explicitly set.
When max_triples is set, parsing stops as soon as the cap is exceeded
(incremental enforcement). Without max_triples, the full graph is
parsed before return — pair with max_bytes on untrusted inputs.
ontosql.import_.parse.load_graph_from_jsonld ¶
load_graph_from_jsonld(doc: dict[str, Any], *, registry: PrefixRegistry | None = None, max_bytes: int | None = None, max_triples: int | None = None, untrusted: bool = False) -> Store
Parse a JSON-LD document dict into a Store.
ontosql.import_.parse.find_subjects_by_type ¶
Return subject IRIs with the given rdf:type.
High-level import¶
ontosql.import_.import_from_rdf ¶
import_from_rdf(data: str | bytes, mapper: type[Any], *, format: str = 'turtle', iri: str | None = None, registry: PrefixRegistry | None = None, max_bytes: int | None = None, max_triples: int | None = None, untrusted: bool = False, max_nesting_depth: int | None = None) -> OntoModel
Hydrate a semantic instance from an RDF serialization.
ontosql.import_.import_from_jsonld ¶
import_from_jsonld(doc: dict[str, Any], mapper: type[Any], *, registry: PrefixRegistry | None = None, max_bytes: int | None = None, max_triples: int | None = None, untrusted: bool = False, max_nesting_depth: int | None = None) -> OntoModel
Hydrate a semantic instance from a JSON-LD document dict.
Security¶
Set untrusted=True and byte/triple limits on public import paths — SECURITY.md.
Related¶
- HYBRID.md — RDF round-trip