2013-02-20 39 views
1

我必须使用新的PostgreSQL HSTORE支持加入到SQLAlchemy的0.8的模型:如何在金字塔中使用SQLAlchemy HSTORE?

class Gateway(Base): 
    __tablename__ = 'gateway' 
    id = Column(Integer, primary_key=True) 
    access = Column(Mutable.as_mutable(HSTORE), nullable=False, unique=True) 

但是当我运行session.query(Gateway).all(),以下异常引发:

ValueError: Attribute 'access' does not accept objects of type <type 'dict'> 

你能帮我解决这个问题?

+0

这是什么sqlalchemy版本? 0.7,0.8? – 2013-02-20 13:05:30

+0

SQLAlchemy 0.8.0b2 – uralbash 2013-02-20 14:07:15

+0

你应该真的包含一个完整的回溯,而不仅仅是异常本身。 – 2013-02-20 14:44:55

回答

4

SQLAlchemy example显示Column使用MutableDict而您正在使用Mutable。这种差异与您看到的错误消息非常吻合。

+0

哇它的作品,我只是chande可变MutableDict – uralbash 2013-02-21 03:07:54