string_to_typeengine

felis.db.utils.string_to_typeengine(type_string, dialect=None, length=None)

Convert a string representation of a datatype to a SQLAlchemy type.

Parameters:
  • type_string (str) – The string representation of the data type.

  • dialect (Dialect | None, default: None) – The SQLAlchemy dialect to use. If None, the default dialect will be used.

  • length (int | None, default: None) – The length of the data type. If the data type does not have a length attribute, this parameter will be ignored.

Returns:

The SQLAlchemy type engine object.

Return type:

sqlalchemy.types.TypeEngine

Raises:

ValueError – Raised if the type string is invalid or the type is not supported.

Notes

This function is used when converting type override strings defined in fields such as mysql:datatype in the schema data.