'SQL Alchemy: add a func(count) result field in each element of my list

I'm struggling to add a number using a func(count) within a car object on sql Alchemy. An example will make it clearer:

query = session.query(Car, func.count(Car.id).label('cars_total'))    
query = Car.query.join(Color, Car.color.id= color.id)
               .group_by(color_id)

The result is something like: [(<Car>, 8), (<Car>, 3), (<Car>, 7)... ] and i'm looking for: `

[<Car>, <Car>, <Car>] with Car[0].__dict__ including the car_total

How can I do that?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source