singer_sdk.connectors.sql.JSONSchemaToSQL

class singer_sdk.connectors.sql.JSONSchemaToSQL[source]

A configurable mapper for converting JSON Schema types to SQLAlchemy types.

This class provides a mapping from JSON Schema types to SQLAlchemy types.

Added in version 0.42.0.

__init__()[source]

Initialize the mapper with default type mappings.

Return type:

None

handle_multiple_types(types)[source]

Handle multiple types by returning a VARCHAR.

Parameters:

types (Sequence[str]) – The list of types to handle.

Returns:

A VARCHAR type.

Return type:

TypeEngine

handle_raw_string(schema)[source]

Handle a string type generically.

Parameters:

schema (dict) – The JSON Schema object.

Returns:

Appropriate SQLAlchemy type.

Return type:

TypeEngine

register_format_handler(format_name, handler)[source]

Register a custom format handler.

Parameters:
  • format_name (str) – The format string (e.g., “date-time”, “email”, “custom-format”).

  • handler (Type[TypeEngine] | Callable[[dict], TypeEngine]) – Either a SQLAlchemy type class or a callable that takes a schema dict and returns a SQLAlchemy type instance.

Return type:

None

register_type_handler(json_type, handler)[source]

Register a custom type handler.

Parameters:
  • json_type (str) – The JSON Schema type to handle.

  • handler (Type[TypeEngine] | Callable[[dict], TypeEngine]) – Either a SQLAlchemy type class or a callable that takes a schema dict and returns a SQLAlchemy type instance.

Return type:

None

to_sql_type(schema)[source]

Convert a JSON Schema type definition to a SQLAlchemy type.

Parameters:

schema (dict) – The JSON Schema object.

Returns:

The corresponding SQLAlchemy type.

Return type:

TypeEngine

property fallback_type: type[TypeEngine][source]

Return the fallback type.

Returns:

The fallback type.