Skip to content

graflo.architecture.onto_sql

Classes

ColumnInfo

Bases: BaseModel

Column information from PostgreSQL table.

Source code in graflo/architecture/onto_sql.py
class ColumnInfo(BaseModel):
    """Column information from PostgreSQL table."""

    name: str
    type: str
    description: str = ""
    is_nullable: str = "YES"
    column_default: str | None = None
    is_pk: bool = False
    is_unique: bool = False
    ordinal_position: int | None = None
    sample_values: list[str] = []
    """Up to 5 sample values from the column (first rows); empty for vertex/edge ColumnInfo."""

Attributes

column_default = None class-attribute instance-attribute
description = '' class-attribute instance-attribute
is_nullable = 'YES' class-attribute instance-attribute
is_pk = False class-attribute instance-attribute
is_unique = False class-attribute instance-attribute
name instance-attribute
ordinal_position = None class-attribute instance-attribute
sample_values = [] class-attribute instance-attribute

Up to 5 sample values from the column (first rows); empty for vertex/edge ColumnInfo.

type instance-attribute

EdgeTableInfo

Bases: BaseModel

Edge table information from schema introspection.

Source code in graflo/architecture/onto_sql.py
class EdgeTableInfo(BaseModel):
    """Edge table information from schema introspection."""

    name: str
    schema_name: str
    columns: list[ColumnInfo]
    primary_key: list[str]
    foreign_keys: list[ForeignKeyInfo]
    source_table: str
    target_table: str
    source_column: str
    target_column: str
    relation: str | None = None

Attributes

columns instance-attribute
foreign_keys instance-attribute
name instance-attribute
primary_key instance-attribute
relation = None class-attribute instance-attribute
schema_name instance-attribute
source_column instance-attribute
source_table instance-attribute
target_column instance-attribute
target_table instance-attribute

ForeignKeyInfo

Bases: BaseModel

Foreign key relationship information.

Source code in graflo/architecture/onto_sql.py
class ForeignKeyInfo(BaseModel):
    """Foreign key relationship information."""

    column: str
    references_table: str
    references_column: str | None = None
    constraint_name: str | None = None

Attributes

column instance-attribute
constraint_name = None class-attribute instance-attribute
references_column = None class-attribute instance-attribute
references_table instance-attribute

RawTableInfo

Bases: BaseModel

Raw table metadata: all tables with columns, types, and constraint metadata.

Source code in graflo/architecture/onto_sql.py
class RawTableInfo(BaseModel):
    """Raw table metadata: all tables with columns, types, and constraint metadata."""

    name: str
    schema_name: str
    """The schema the catalog lists the table in; empty where the engine has none."""
    description: str = ""
    """The table's comment, when the engine stores one."""
    columns: list[ColumnInfo]
    primary_key: list[str]
    foreign_keys: list[ForeignKeyInfo]
    row_count_estimate: int | None = None
    """Approximate row count from pg_class.reltuples (updated by ANALYZE)."""

Attributes

columns instance-attribute
description = '' class-attribute instance-attribute

The table's comment, when the engine stores one.

foreign_keys instance-attribute
name instance-attribute
primary_key instance-attribute
row_count_estimate = None class-attribute instance-attribute

Approximate row count from pg_class.reltuples (updated by ANALYZE).

schema_name instance-attribute

The schema the catalog lists the table in; empty where the engine has none.

ReferenceEdgeInfo

Bases: BaseModel

An edge stated by a foreign key inside an entity table.

Source code in graflo/architecture/onto_sql.py
class ReferenceEdgeInfo(BaseModel):
    """An edge stated by a foreign key inside an entity table."""

    source_table: str
    target_table: str
    relation: str
    columns: dict[str, str]
    """``{key column of the target: foreign-key column of the source}``."""

Attributes

columns instance-attribute

{key column of the target: foreign-key column of the source}.

relation instance-attribute
source_table instance-attribute
target_table instance-attribute

SchemaIntrospectionResult

Bases: BaseModel

Result of PostgreSQL schema introspection.

Source code in graflo/architecture/onto_sql.py
class SchemaIntrospectionResult(BaseModel):
    """Result of PostgreSQL schema introspection."""

    vertex_tables: list[VertexTableInfo]
    edge_tables: list[EdgeTableInfo]
    raw_tables: list[RawTableInfo]
    schema_name: str
    reference_edges: list[ReferenceEdgeInfo] = []
    skipped_tables: list[SkippedTableInfo] = []

Attributes

edge_tables instance-attribute
raw_tables instance-attribute
reference_edges = [] class-attribute instance-attribute
schema_name instance-attribute
skipped_tables = [] class-attribute instance-attribute
vertex_tables instance-attribute

SkippedTableInfo

Bases: BaseModel

A table that is neither a vertex nor an edge of the inferred graph.

Source code in graflo/architecture/onto_sql.py
class SkippedTableInfo(BaseModel):
    """A table that is neither a vertex nor an edge of the inferred graph."""

    name: str
    reason: str

Attributes

name instance-attribute
reason instance-attribute

VertexTableInfo

Bases: BaseModel

Vertex table information from schema introspection.

Source code in graflo/architecture/onto_sql.py
class VertexTableInfo(BaseModel):
    """Vertex table information from schema introspection."""

    name: str
    schema_name: str
    columns: list[ColumnInfo]
    primary_key: list[str]
    foreign_keys: list[ForeignKeyInfo]
    unique_constraints: list[list[str]] = []
    """Column lists of the table's UNIQUE constraints, single- and multi-column."""

Attributes

columns instance-attribute
foreign_keys instance-attribute
name instance-attribute
primary_key instance-attribute
schema_name instance-attribute
unique_constraints = [] class-attribute instance-attribute

Column lists of the table's UNIQUE constraints, single- and multi-column.