Typing

Public type aliases, metadata types, and protocol definitions used throughout SQLSpec.

Metadata Types

class sqlspec.typing.ForeignKeyMetadata[source]

Bases: object

Metadata for a foreign key constraint.

__init__(table_name, column_name, referenced_table, referenced_column, constraint_name=None, schema=None, referenced_schema=None)[source]
class sqlspec.typing.ColumnMetadata[source]

Bases: TypedDict

Metadata for a database column.

class sqlspec.typing.TableMetadata[source]

Bases: TypedDict

Metadata for a database table.

class sqlspec.typing.IndexMetadata[source]

Bases: TypedDict

Metadata for a database index.

class sqlspec.typing.VersionInfo[source]

Bases: object

Parsed database version info.

__init__(major, minor=0, patch=0)[source]

Initialize version info.

Parameters:
  • major (int) – Major version number

  • minor (int) – Minor version number

  • patch (int) – Patch version number

property version_tuple: tuple[int, int, int]

Get version as tuple for comparison.

__str__()[source]

String representation of version info.

Return type:

str

__repr__()[source]

Detailed string representation.

Return type:

str

__eq__(other)[source]

Check version equality.

Return type:

bool

__lt__(other)[source]

Check if this version is less than another.

Return type:

bool

__le__(other)[source]

Check if this version is less than or equal to another.

Return type:

bool

__gt__(other)[source]

Check if this version is greater than another.

Return type:

bool

__ge__(other)[source]

Check if this version is greater than or equal to another.

Return type:

bool

__hash__()[source]

Make VersionInfo hashable based on version tuple.

Return type:

int

Protocols

class sqlspec.typing.DictLike[source]

Bases: Protocol

A protocol for objects that behave like a dictionary for reading.

__init__(*args, **kwargs)

Feature Flags

class sqlspec.data_dictionary.FeatureFlags[source]

Bases: TypedDict

Typed feature flags for data dictionary dialects.

class sqlspec.data_dictionary.FeatureVersions[source]

Bases: TypedDict

Typed feature version requirements for data dictionary dialects.

Driver Protocols