from sqlalchemy import Column, Integer, String def get_field(field_attrs: dict) -> Column: """ Construct sqlalchemy field using dictionary with field attributes. Returns the sqlalchemy column. :param field_attrs: The dictionary with field attributes. """ column_attrs = {} for key, value in field_attrs.items(): if key == "type": match value: case "str": column_attrs["type_"] = String case "int": column_attrs["type_"] = Integer case "file": column_attrs["type_"] = String elif key == "nullable": column_attrs["nullable"] = value return Column(**column_attrs)