Skip to content

schema

relationalai.semantics.inspect
schema(model: Model) -> ModelSchema

Return the complete schema of model as frozen dataclasses.

One call gives you every concept, property, relationship, table, and enum in the model — including inherited properties and relationships. No engine connection needed.

Output order is deterministic: top-level model collections follow declaration order, while per-concept members follow effective lookup order after inheritance and shadowing.

Parameters

  • model

    (Model) - The PyRel model to inspect.

Returns

  • ModelSchema - A frozen, structured description of the entire model schema.

Examples

from relationalai.semantics import Model, Integer, String, inspect
m = Model("example")
Person = m.Concept("Person", identify_by={"id": Integer})
Person.name = m.Property(f"{Person} has {String:name}")
ms = inspect.schema(m)
ms["Person"].identify_by[0].type_name
# 'Integer'
ms["Person"].properties[0].name
# 'name'