小编Nig*_*uki的帖子

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

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

例如:

{
    "facebook": {
        "openid": "123456789",
        "access_token": "6EFD26B0A868E3BB387E78851E42943F"
    }
}
Run Code Online (Sandbox Code Playgroud)

我知道openid的值,但access_token是不确定的.

我尝试了以下但它引发了一个错误.

cls.query.filter(User.auth["facebook"]["openid"].astext == openid).first()
Run Code Online (Sandbox Code Playgroud)

python postgresql json sqlalchemy

5
推荐指数
1
解决办法
2517
查看次数

标签 统计

json ×1

postgresql ×1

python ×1

sqlalchemy ×1