SQLAlchemy Return All Distinct Column Values

后端 未结 4 2012
时光取名叫无心
时光取名叫无心 2021-02-07 10:45

I am creating a website using Flask and SQLAlchemy. This website keeps track of classes that a student has taken. I would like to find a way to search my database using SQLAlc

4条回答
  •  余生分开走
    2021-02-07 10:46

    query = session.query(Class.title.distinct().label("title"))
    titles = [row.title for row in query.all()]
    

提交回复
热议问题