1

I have a JSONB column,

count = db.Column(JSONB)

Stored in this column is an array of json objects,

[{'uuid':'xxx-xxx-xxxx', 'bwl_click_count':'5'},{'uuid':'xxx-xxx-yyyy', 'bwl_click_count':'18'} ...]

I've tried querying it several ways, and can't find any way to extract a specific uuid from the list. I tried the following,

db.session.query(bwl_value).filter(bwl_value.bwl_count["uuid"].astext == "xxx-xxx-xyyyxxx").all()

but this returns an empty array.

Can anyone suggest a way to do this?

Thanks in advance!

Ilja Everilä
  • 50,538
  • 7
  • 126
  • 127
Hazzamataza
  • 983
  • 2
  • 12
  • 25
  • You could use the JSONB containment check: https://stackoverflow.com/questions/52190109/how-to-query-json-array-in-postgres-with-sqlalchemy, or maybe the new JSON path funtions in 12. – Ilja Everilä Dec 02 '19 at 07:39

0 Answers0