Selecting distinct column values in SQLAlchemy/Elixir
You can query column properties of mapped classes and the Query class has a generative distinct()
method:
for value in Session.query(Table.column).distinct(): pass
For this class:
class Assurance(db.Model): name = Column(String)
you can do this:
assurances = []for assurance in Assurance.query.distinct(Assurance.name): assurances.append(assurance.name)
and you will have the list of distinct values
for user in session.query(users_table).distinct(): print user.posting_id