2024-09-28 03:23:58 发布
网友
我知道我可以使用以下示例查询轻松查询JSON值:
r = Books.query.filter( Books.nameofjsonfield['key1', 'key2'].astext.cast(Unicode) == 'exact_string_to_compare' ).all()
但如何搜索与JSON值的子字符串匹配的数据集呢
将值转换为文本后,只需using ^{} one way or the other或任何其他模糊匹配方法:
r = Books.query.\ filter(Books.nameofjsonfield['key1', 'key2']. astext. cast(Unicode). contains('not_so_exact_string_to_find')).\ all()
将值转换为文本后,只需using ^{} one way or the other 或任何其他模糊匹配方法:
相关问题 更多 >
编程相关推荐