1

I'm writing code similar to the example below, but it feels clunky. Is there a better way to get a flat list out of a SQLAlchemy query? If I don't do the list comprehension, the list is a list of tuples.

names = [x[0] for x in session.query(User.name).all()]

I'd like some magical function like Query.scalar but for a list.

Jim Hunziker
  • 14,111
  • 8
  • 58
  • 64

0 Answers0