uralbash
uralbash

Reputation: 3598

How to use SQLAlchemy HSTORE in Pyramid?

I have a model using the new PostgreSQL HSTORE support added to SQLAlchemy 0.8:

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

But when I run session.query(Gateway).all(), the following exception is raised:

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

Could you help me to solve this problem?

Upvotes: 1

Views: 1406

Answers (1)

Michael Merickel
Michael Merickel

Reputation: 23331

The SQLAlchemy example shows the Column using a MutableDict whereas you are using Mutable. This discrepancy lines up pretty well with the error message you are seeing.

Upvotes: 4

Related Questions