pydantic-sqlalchemy
pydantic-sqlalchemy copied to clipboard
Error with MySQL DateTime! str type expected (type=type_error.str)
I have created my model from pre-existing MySQL database everything working fine butt when I add DateTime: str gives error. str type expected (type=type_error.str)
from pydantic import BaseModel from datetime import datetime
class YourPydanticModel(BaseModel): datetime_column: datetime # Use appropriate datetime type here
Example usage
data = { "datetime_column": "2023-09-03T12:34:56" # Replace with your actual datetime string }
pydantic_instance = YourPydanticModel(**data) print(pydantic_instance)