2011-05-11 62 views
1

我与声明定义的,我敢肯定,这是非常快的回答,但我一直没能找到它谷歌搜索一个问题...SQLAlchemy的:得到一些列别名

我有一类产品SQLAlchemy的:

class Product(declarativeBase): 
    __tablename__ = "products" 
    _brand = Column("brand", Unicode(128)) 
    _series = Column("series", String(128)) 
    _price = Column("price", Float) 
    _description = Column("description", UnicodeText) 

    _manufacturerId = Column("manufacturer_id", Integer, ForeignKey("manufacturers.id"), key="manufacturerId") 
    _manufacturer = relationship("Manufacturer", 
     uselist=False, 
     backref=backref("_products", collection_class=set) 
     ) 

和AA某一点,我想所有的产品,如_brand和_manufacturerId的某些列,但不是获取它命名_manufacturerId我想叫_manufacturer(主要是“隐藏”关系的事情)。

我不知道该怎么做......这将是这样的:

session.query(Product.Product._brand, Product.Product._manufacturerId as "_manufacturer").all() 

我敢肯定这是可行的,但我不知道如何(使用SQLAlchemy的0.6。 6,以防万一)

非常感谢!

回答