On Monday, April 23, 2018 at 9:18:02 PM UTC-4, jacqueline.wel...@gmail.com wrote: > > Hello, > > I'm wondering if there is a way to query a JSON object once its been > inserted into a SQLite table? > I have a Program table with a column : > > Field('performance_json', > type='json') > > and I'm trying to query based on this JSON's data within a simple JSON > object > {"name": name, "age": 25} > > Is there a clean way to query the JSON object? >
In SQLite, probably the best you can do is: db(db.mytable.performance_json.contains('"name": "%s"' % name) & db.mytable.performance_json.contains('"age": 25')).select() In databases that do not support JSON natively (such as SQLite), the JSON is simply stored as a string, so you can use the usual text search methods to match the relevant fragments of JSON. Anthony -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.