Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python SQLAlchemy过滤PostgreSQL JSONB中的嵌套JSON数据_Python_Json_Postgresql_Sqlalchemy - Fatal编程技术网

Python SQLAlchemy过滤PostgreSQL JSONB中的嵌套JSON数据

Python SQLAlchemy过滤PostgreSQL JSONB中的嵌套JSON数据,python,json,postgresql,sqlalchemy,Python,Json,Postgresql,Sqlalchemy,我将嵌套JSON存储为jsonb,但我不知道如何选择具有不确定值的嵌套JSON e、 g: 我知道openid的值,但access_令牌不确定 我尝试了以下操作,但出现了一个错误 cls.query.filter(User.auth["facebook"]["openid"].astext == openid).first() dict={“facebook”:{“openid”:“123456789”}user=cls.query.filter(user.auth.contains(dict

我将嵌套JSON存储为jsonb,但我不知道如何选择具有不确定值的嵌套JSON

e、 g:

我知道openid的值,但access_令牌不确定

我尝试了以下操作,但出现了一个错误

cls.query.filter(User.auth["facebook"]["openid"].astext == openid).first()

dict={“facebook”:{“openid”:“123456789”}
user=cls.query.filter(user.auth.contains(dict)).first()
生效jsonb操作符:@Nightsuki非常感谢,你是我的救命恩人!顺便说一句,我猜你是诺佐米的粉丝?相关:。要访问嵌套对象,还可以使用
User.auth[“facebook”,“openid”]。astext==“123456789”
cls.query.filter(User.auth["facebook"]["openid"].astext == openid).first()