Skip to content

inference

sqllocks_spindle.schema.inference

Smart Schema Inference Engine.

Takes a basic DDL-parsed SpindleSchema and enhances it with realistic generation strategies inferred from schema structure: table roles, column semantics, FK distributions, temporal patterns, and business rules.

Usage

from sqllocks_spindle.schema import DdlParser from sqllocks_spindle.schema.inference import SchemaInferenceEngine

schema = DdlParser().parse_file("my_tables.sql") smart_schema = SchemaInferenceEngine().infer(schema)

Classes

TableRole

Bases: Enum

Semantic role of a table in the schema.

ColumnSemantic

Bases: Enum

Semantic role of a column.

InferenceAnnotation dataclass

Explanation of a single inference decision.

InferenceContext dataclass

Accumulated analysis state passed through the analyzer pipeline.

Methods:
build_graphs()

Build parent/child relationship graphs from schema.

Analyzer

Bases: Protocol

Interface for inference pipeline stages.

SchemaInferenceEngine

Enhance a basic DDL-parsed schema with smart inferences.

Usage

engine = SchemaInferenceEngine() smart_schema = engine.infer(basic_schema)

Methods:
infer(schema)

Run the full inference pipeline and return an enhanced schema.

infer_with_report(schema)

Run inference and return both the schema and the explanation report.