how can i query data filtered by a JSON Column in SQLAlchemy?
According to the documentation, it can be done using
from sqlalchemy.types import Unicode Custom.query.filter(Custom.data['value'].astext.cast(Unicode) == "what I want")
Assuming that your table is name "custom" and your json field is named "data" the following sql statement will get your results where the value subfield is equal to "what I want".
sql = text("select * from custom where data->>'value'= 'what I want'") result = db.engine.execute(sql)