title: How to do group_by query using SQLAlchemy in Python?
body: <p>I have 2 tables as provided below which are already populated, </p>
  
  <pre><code>class Shelter(Base):
  
      __tablename__ = 'shelter'
      id = Column(Integer, primary_key = True)
      name = Column(String(80), nullable = False)
      address = Column(String(250))
      city = Column(String(80))
      state = Column(String(20))
      zipCode = Column(String(10))
      website = Column(String)
  
  
  class Puppy(Base):
  
      __tablename__ = 'puppy'
  
      id = Column(Integer, primary_key=True)
      name = Column(String(250), nullable=False)
      gender = Column(String(6), nullable = False)
      dateOfBirth = Column(Date)
      picture = Column(String)
      shelter_id = Column(Integer, ForeignKey('shelter.id'))
      shelter = relationship(Shelter)
      weight = Column(Numeric(10))
  </code></pre>
  
  <p>Now, I would like to write an query for get all the Puppies group by their Shelter name using Python. So, it will need to be printed as <code>puppyName puppyShelterName</code>. </p>
  
  <p>I write the code as following, </p>
  
  <pre><code>puppies = session.query(Puppy).group_by(Puppy.shelter_id).all()
  
  for puppy in puppies:
      puppy.name
  </code></pre>
  
  <p>This is obviously not working as I wanted. I would like to print all the puppies name with their shelter name group by in which shelter they are staying. How to correct the code ? </p>