I use the SQLAlchemy recipe here to magically JSON encode / decode a column from a DB in my model, for example:
class Thing(Base):
__tablename__ = 'things'
id = Column(Integer(), primary_key=True)
data = Column(JSONEncodedDict)
I hit when I wanted to create an additional "raw_data" field in my model to access the same basic JSON data, but without encoding / decoding:
raw_data = Column("data", VARCHAR)
SQLAlchemy seems to get confused by name collision and leaves one column unmapped. Is there a way to convince SQLAlchemy to actually match both attributes to the same column?
source
share