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 input syntax for
type json
LINE 3: WHERE jtable.data @> 'third'
^
DETAIL: Token "third" is invalid.
CONTEXT: JSON data, line 1: third
[SQL: 'SELECT jtable.data \nFROM jtable \nWHERE jtable.data @>
%(data_1)s'] [parameters: {'data_1': 'third'}]
torstai 31. joulukuuta 2015 16.11.47 UTC+2 Jon Rosebaugh kirjoitti:
>
> 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'].contains('third')).
>
>
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.