2014-02-25 35 views
0

我是新來瓶不安,並尋找一種方法來做一個「SELECT DISTINCT」的表。我一直在閱讀文檔,並發現「功能評估」。但是我找不到如何將函數評估放入預處理器中,還是我絕對錯誤? 有人知道如何做到這一點?如何「選擇不同」與燒瓶不安寧

回答

0

函數求值只返回計算函數的值,例如count,max,avg。我不認爲這是在挖好辦法。

你或許應該嵌入在你的類自定義查詢去,如自定義查詢https://flask-restless.readthedocs.org/en/latest/customizing.html#custom-queries

from sqlalchemy import distinct 

class Person(Base): 
    __tablename__ = 'person' 
    id = Column(Integer, primary_key=True) 
    name = Column(Unicode(50)) 

    @classmethod 
    def query(cls): 

     return cls.query(func.distinct(Person.name)) 
顯示