Sqlalchemy json column - how to perform filter based on list of ids on a key

29 views
Skip to first unread message

pradam

unread,
Oct 8, 2018, 11:06:44 PM10/8/18
to django...@googlegroups.com

I have a list of ids like:

tracker_ids = [69, 70]

I need to get all the APInformation objects based on the tracker_id.

data looks like this:

{ 'tracker_id' : 69, 'cpu_core_avg': 89.890', 'is_threshold': true,'datetime':1539053379040 }
{ 'tracker_id' : 70, 'cpu_core_avg': 65.0', 'is_threshold': false, 'datetime':1539053379040 }
{ 'tracker_id' : 69, 'cpu_core_avg': 34.9', 'is_threshold': false,'datetime':1539053379040 }

I tried the following but it raises an error.

session.query(APInformation).filter(APInformation.data['tracker_id'].in_(tracker_ids), APInformation.data['datetime'].astext.cast(BigInteger) > 1539053379040).all()


I dont know where i am missing the point?

Thank you

siddharth anvekar

unread,
Oct 10, 2018, 1:05:17 PM10/10/18
to django...@googlegroups.com
( tracker_id : 69, cpu_core : 89.890
Datetime: 15 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAGGVXBNP4dxU8t75aGgSxbicS3FjKkthTDUiOmAehf6f3rPWjQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages