1

我有一个模型使用添加到 SQLAlchemy 0.8 的新 PostgreSQL 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'>

你能帮我解决这个问题吗?

4

1 回答 1

4

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

于 2013-02-20T18:40:03.153 回答