code: def cast_callback(value):
          
          # Postgresql / MySQL drivers change the format on 'TIMESTAMP' columns;
  
          if 'T' in value:
              value = value.replace('T', ' ')
  
          return datetime.strptime(value.split('.')[0], '%Y-%m-%d %H:%M:%S')
docs: Override `cast_callback` method.