SQLAlchemy get list of ids from a query

python, sqlalchemy

Solution

SQL

 SELECT DISTINCT `id` FROM `table`;

Python

 for value in Session.query(Table.id).distinct():
     #Do something Append

Problem

How do I get a list of ids instead of a list of SQLAlchemy objects? Currently I'm doing this: ``` [x.id for x in random_query.all()] ``` Is there a better way of doing this, preferably by only using SQLAlchemy statements.

Original source