python - SQL Alchemy: Select entire row by distinct column_a and max column_b -


consider model:

class pet(db.model):     id = primary_key     type_of_pet = string_column     name = string_column     foo_relation = int_column     added_time = int_column 

say there 100 entries in table , 20 different pet types (cats, dogs, turtles, rabbits, etc).

is possible recent additions each pet type in single query?

i thought like:

unique_pets = pet.query.distinct(pet.type_of_pet).limit(5) 

would work distinct more returning list of unique column names , not full row results.

any insight appreciated. note aws aurora (mysql) server


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -