Typing#
Public type aliases, metadata types, and protocol definitions used throughout SQLSpec.
Optional dependency exports#
The sqlspec.typing module and its private sqlspec._typing backing module resolve heavy
optional-dependency symbols lazily. Importing sqlspec does not import
Pydantic, Litestar, PyArrow, pandas, Polars, OpenTelemetry, or Prometheus.
Accessing one of their exported symbols imports its dependency on first use and
caches the resolved object:
import sqlspec.typing as sqlspec_typing
arrow_table_type = sqlspec_typing.ArrowTable # Imports PyArrow here.
When an optional dependency is not installed, the same access returns a stable typed shim. Repeated access returns the identical real object or shim, preserving annotation and runtime identity behavior. Features that require the dependency still raise the normal missing-dependency error when enabled.
msgspec remains eager because its core types and conversion functions are
used throughout result mapping and serialization. orjson also remains on
the existing eager path; both have a small measured import cost compared with
the deferred integrations.
Metadata Types#
- class sqlspec.data_dictionary.ForeignKeyMetadata[source]#
Bases:
objectMetadata for a foreign key constraint.
- class sqlspec.data_dictionary.ColumnMetadata[source]#
Bases:
TypedDictMetadata for a database column.
- class sqlspec.data_dictionary.TableMetadata[source]#
Bases:
TypedDictMetadata for a database table.
- class sqlspec.data_dictionary.IndexMetadata[source]#
Bases:
TypedDictMetadata for a database index.