title: Fast API - MySQL - SQLAlchemy: Get ValidationError 'Invalid type' in Pydantic Model
body: <p>I'm fairly new to this framework, but i'm working on a timesheet application (API) for a small company.</p>
  <p>The issue i have is that when i select a time value from mysql i got the following error in the pydantic module:</p>
  <pre><code>pydantic.error_wrappers.ValidationError: 2 validation errors for TimeSheetRange 
  response -&gt; 0 -&gt; total   
  invalid type; expected time, string, bytes, int or float (type=type_error) 
  response -&gt; 1 -&gt; total   
  invalid type; expected time, string, bytes, int or float (type=type_error)
  </code></pre>
  <p>I have tried a lot of workarounds to get the time to string from mysql with <code>to_char()</code> which also failed, but i rather want to know what the issue is here as i would like to use the data type time...</p>
  <p>schemas.py</p>
  <pre class="lang-py prettyprint-override"><code>from typing import List, Optional
  from datetime import date, time, datetime
  
  from pydantic import BaseModel
  from . import models
  
  ...
  
  
  class TimeSheetRange(BaseModel):
      user_id: int
      start: date
      total: time
  
      class Config:
          orm_mode = True
  </code></pre>
  <p>crud.py</p>
  <pre class="lang-py prettyprint-override"><code>def get_timesheet_by_date_range_and_user(db: Session, user_id=int, date_start=datetime, date_end=datetime):
      return db.query(models.TimeSheet.user_id, \
                      func.date(models.TimeSheet.start).label('start'), \
                      func.sec_to_time(func.sum(func.timediff(models.TimeSheet.end,models.TimeSheet.start))).label('total') ) \
              .filter(models.TimeSheet.user_id == user_id) \
              .filter(func.date(models.TimeSheet.start) &gt;= date_start) \
              .filter(func.date(models.TimeSheet.end) &lt;= date_end) \
              .group_by(func.date(models.TimeSheet.start)) \
              .all()
  </code></pre>
  <p>main.py</p>
  <pre class="lang-py prettyprint-override"><code>@app.get(&quot;/timesheets/range/&quot;, response_model=List[schemas.TimeSheetRange])
      def read_timesheets(user_id: int, date_start:date = datetime.now().date(), date_end:date = datetime.now().date(), db: Session = Depends(get_db)):
          timesheets = crud.get_timesheet_by_date_range_and_user(db, user_id=user_id, date_start=date_start, date_end=date_end)
          return timesheets
  </code></pre>
  <p>And the SQL Query that is build with a result:</p>
  <pre class="lang-sql prettyprint-override"><code>SELECT 
      timesheet.user_id AS timesheet_user_id, 
      date(timesheet.start) AS start,
      sec_to_time(sum(timediff(timesheet.end, timesheet.start))) AS total  
  FROM 
      timesheet  
  WHERE 
      timesheet.user_id = 7 
  AND  
      date(timesheet.start) &gt;= '2020-09-20' 
  AND 
      date(timesheet.end) &lt;= '2020-09-22' 
  GROUP BY 
      date(timesheet.start);
  +-------------------+------------+----------+
  | timesheet_user_id | start      | total    |
  +-------------------+------------+----------+
  |                 7 | 2020-09-20 | 17:50:47 |
  |                 7 | 2020-09-21 | 18:21:11 |
  +-------------------+------------+----------+
  </code></pre>
  <p>Is there something wrong with the datatype <code>time</code> or am i missing something really stupid?</p>