[sqlalchemy] Re: Not able to filter json column filter in flask-sqlalchemy

2017-12-08 Thread shrey . chauhan
One more doubt is, is there a way to filter on the full json something like this: in your example only: print(Session.query(Student).filter(Student.data_test =={'foo':'bar'}).first()) -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post

[sqlalchemy] Re: Not able to filter json column filter in flask-sqlalchemy

2017-12-07 Thread shrey . chauhan
*VERSION* it was, was working with pg9.2, upgraded to pg9.6 and everything works fine now. Thank you so much. -- 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

Re: [sqlalchemy] Re: Not able to filter json column filter in flask-sqlalchemy

2017-12-07 Thread Антонио Антуан
What is the version of your PostgreSQL? Here is an example. Works perfectly for me (pg9.6 and pg10). https://gist.github.com/aCLr/7d794eabbf972a60a15f40b2d3965508 чт, 7 дек. 2017 г. в 16:05, : > Hi, > > I tried using direct plain JSON: > > my model > class

[sqlalchemy] Re: Not able to filter json column filter in flask-sqlalchemy

2017-12-07 Thread shrey . chauhan
Hi, I tried using direct plain JSON: my model class Student(db.Model): __tablename__= 'students' id=db.Column(db.Integer, primary_key=True,autoincrement=True) name=db.Column(db.String(200)) roll_no=db.Column(db.Integer) data_test=db.Column(db.JSON) I tried this: *a =

Re: [sqlalchemy] Re: Not able to filter json column filter in flask-sqlalchemy

2017-12-07 Thread Антонио Антуан
you can call "->>" (and any other) operator directly: Student.data_test.op('->>')('foo') == 'bar' if you want to call cast use this: cast(Student.data_test['foo'], String) == 'bar' "c" (the shortcut for "columns") allows for "Table" instances. If you use declarative style, you can not to use it

[sqlalchemy] Re: Not able to filter json column filter in flask-sqlalchemy

2017-12-06 Thread shrey . chauhan
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 =