Hi Mike, as you said I tried this:
*from sqlalchemy.dialects import postgresql class Student(db.Model): # ... data_test=db.Column(postgresql.JSON) * and I tried querying like this: *a = Student.query.filter(Student.data_test["foo"].astext =="bar").first()* tried this as well: *a = Student.query.filter(Student.data_test["foo"].astext.cast(String)=="bar").first()* But still I am getting error: Traceback (most recent call last): File "sqlalchemyjson.py", line 46, in <module> a = Student.query.filter(Student.data_test["foo"].astext =="bar").first() File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/query.py", line 2690, in first ret = list(self[0:1]) File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/query.py", line 2482, in __getitem__ return list(res) File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/query.py", line 2790, in __iter__ return self._execute_and_instances(context) File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/query.py", line 2813, in _execute_and_instances result = conn.execute(querycontext.statement, self._params) File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 945, in execute return meth(self, multiparams, params) File "/usr/lib64/python2.7/site-packages/sqlalchemy/sql/elements.py", line 263, in _execute_on_connection return connection._execute_clauseelement(self, multiparams, params) File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1053, in _execute_clauseelement compiled_sql, distilled_params File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1189, in _execute_context context) File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1393, in _handle_dbapi_exception exc_info File "/usr/lib64/python2.7/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause reraise(type(exception), exception, tb=exc_tb, cause=cause) File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context context) File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/default.py", line 470, in do_execute cursor.execute(statement, parameters) sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) operator does not exist: json ->> unknown LINE 3: WHERE (students.data_test ->> 'foo') = 'bar' When I use plain json, what should be my query? *a = Student.query.filter(cast(**Student**.c.data_test["foo"], String) =="bar").first()* I am getting this: AttributeError: type object 'Student' has no attribute 'c' Where am I going wrong? -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.