Re: [sqlalchemy] Searching from jsonb list

2015-12-31 Thread Sami Pietilä
Perhaps there is something wrong with my select. I tried with following select and got an error message below: select([database.tables['jtable'].c['data']]).where(database.tables['jtable'].c['data'].contains('third')) --- Error Message --- sqlalchemy.exc.DataError: (psycopg2.DataError) invalid in

Re: [sqlalchemy] Searching from jsonb list

2015-12-31 Thread Jon Rosebaugh
Your SQL itself isn't going to work; there's no 'item' column in your select statement. You should read http://www.postgresql.org/docs/9.4/interactive/functions-json.html to see what operators you have. (I think you want '@>', not LIKE.) In SQLAlchemy, this would be done as .where(mytable.c['data

[sqlalchemy] Searching from jsonb list

2015-12-31 Thread Sami Pietilä
Hi, I am looking for an example how to use sqlalchemy core to search an item from a column having a jsonb list. I have PosgreSQL database having following example table from which I am searching an item: create table jtable (data jsonb); insert into jtable (data) values ('["first","second"]');