Selecting distinct column values in SQLAlchemy/Elixir
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
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