Typing & Schema Aliases¶
from sqlspec.typing import (
UNSET,
ArrowReturnFormat,
ConnectionT,
DataclassProtocol,
DictLike,
Empty,
EmptyType,
PoolT,
SchemaT,
StatementParameters,
SupportedSchemaModel,
UnsetType,
get_type_adapter,
)
Public type variables, schema model union aliases, Apache Arrow return format literals, and sentinel types exported by sqlspec.typing. See Schema Mapping for usage examples.
Core Type Variables & Aliases¶
ConnectionT
¶
Type variable for connection types.
:class:~sqlspec.typing.ConnectionT
SchemaT
¶
Type variable for schema types (models, TypedDict, dataclasses, etc.).
Unbounded TypeVar for use with schema_type parameter in driver methods. Supports all schema types including TypedDict which cannot be bounded to a class hierarchy.
SupportedSchemaModel
¶
SupportedSchemaModel = (
DictLike
| StructStub
| BaseModelStub
| DataclassProtocol
| AttrsInstanceStub
| Mapping[str, Any]
)
Type alias for pydantic or msgspec models.
:class:msgspec.Struct | :class:pydantic.BaseModel | :class:DataclassProtocol | :class:AttrsInstance
StatementParameters
¶
Type alias for statement parameters.
Represents
- :type:
dict[str, object] - :type:
list[object] - :type:
tuple[object, ...] - :type:
object - :type:
None
ArrowReturnFormat
¶
Type alias for Apache Arrow return format options.
Represents
- :literal:
"table"- Return PyArrow Table - :literal:
"reader"- Return PyArrow RecordBatchReader - :literal:
"batch"- Return single PyArrow RecordBatch - :literal:
"batches"- Return list of PyArrow RecordBatches
Schema Protocols & Adapter Helpers¶
get_type_adapter
¶
Caches and returns a pydantic type adapter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
f
|
type[T]
|
Type to create a type adapter for. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
class: |
Sentinel Types & Optional Dependency Flags¶
| Constant | Description |
|---|---|
UNSET |
Singleton sentinel indicating an omitted optional parameter. |
Empty |
Legacy sentinel alias for omitted parameters. |
MSGSPEC_INSTALLED |
True when msgspec is available at runtime. |
PYDANTIC_INSTALLED |
True when pydantic is available at runtime. |
ATTRS_INSTALLED |
True when attrs is available at runtime. |
CATTRS_INSTALLED |
True when cattrs is available at runtime. |
PYARROW_INSTALLED |
True when pyarrow is available at runtime. |
POLARS_INSTALLED |
True when polars is available at runtime. |
PANDAS_INSTALLED |
True when pandas is available at runtime. |
NUMPY_INSTALLED |
True when numpy is available at runtime. |
LITESTAR_INSTALLED |
True when litestar is available at runtime. |
OPENTELEMETRY_INSTALLED |
True when opentelemetry-api is available at runtime. |
PROMETHEUS_INSTALLED |
True when prometheus-client is available at runtime. |
FSSPEC_INSTALLED |
True when fsspec is available at runtime. |
OBSTORE_INSTALLED |
True when obstore is available at runtime. |