Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLAlchemy and scalar values [duplicate]

I have simple question regarding SQLAlchemy, is it possible to get the rows from the result as scalars instead of tuples? In other words I want an equivalent to:

[i[0] for i in self.archive.query(IRTerm.term).distinct()]

Thank you

like image 492
honzas Avatar asked Feb 16 '10 12:02

honzas


1 Answers

No built in way in SQLAlchemy, but with python it isn't too hard. The example you gave works fine. You can also do map(itemgetter(0), query) or for value, in query:.

like image 112
Ants Aasma Avatar answered Oct 01 '22 11:10

Ants Aasma