Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/365.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 如何使用pyrebase查询?_Python_Django_Firebase_Pyrebase - Fatal编程技术网

Python 如何使用pyrebase查询?

Python 如何使用pyrebase查询?,python,django,firebase,pyrebase,Python,Django,Firebase,Pyrebase,我正在学习如何使用python、django和pyrebase查询。我在查询多个key值时遇到问题 例如: 这是我的数据结构: { "root": { "account": { "ACC0001": { "id": "ACC0001", "create_day"

我正在学习如何使用python、django和pyrebase查询。我在查询多个key值时遇到问题

例如:

这是我的数据结构:

    {
    "root": {
        "account": {
            "ACC0001": {
                "id": "ACC0001",
                "create_day": "2020-04-20 16:56:11",
                "create_by": "USE001",
                "brief_name": "AAAAA",
                "status": "active"
            },
            "ACC0002": {
                "id": "ACC0002",
                "create_day": "2020-04-20 16:56:12",
                "create_by": "USE002",
                "brief_name": "BBBBB",
                "status": "inactive"
            },
            "ACC0003": {
                "id": "ACC0003",
                "create_day": "2020-04-20 16:56:13",
                "create_by": "USE003",
                "brief_name": "CCCCC",
                "status": "active"
            },
            "ACC0004": {
                "id": "ACC0004",
                "create_day": "2020-04-20 16:56:14",
                "create_by": "USE004",
                "brief_name": "DDDDD",
                "status": "inactive"
            },
            "ACC0005": {
                "id": "ACC0005",
                "create_day": "2020-04-20 16:56:15",
                "create_by": "USE005",
                "brief_name": "EEEEE",
                "status": "inactive"
            },
            
            ......

            "ACC9999": {
                "id": "ACC9999",
                "create_day": "2020-04-20 16:56:15",
                "create_by": "USE100",
                "brief_name": "FFFFF",
                "status": "active"
            }
        }
    }
}
在SQL中,我使用类似于“从AAA中选择*,其中D='active'和(i='USE002'或i='USE003'或i='USE004'或i='USE005')” 如何在python、django和pyrebase中获取列表用户的记录?我只得到一个用户。我的代码如下:

    config = {
    'apiKey': "xxxxxx",
    'authDomain': "xxxx.firebaseapp.com",
    'databaseURL': "https://xxxx.firebaseio.com",
    'projectId': "xxxx-92dec",
    'storageBucket': "xxxx-92dec.appspot.com",
    'messagingSenderId': "xxxx598699",
    'appId': "1:xxxxx8699:web:xxxxx5a9e2920ec32e",
    'measurementId': "xxxx360FN"
    }

firebase = pyrebase.initialize_app(config)
database = firebase.database()
// how can get all record of list create_by ['USE001','USE002','USE003'...]
objuser = database.child('account').order_by_child('create_by').equal_to('USE001').get().val()

Firebase实时数据库不允许查询位置

实现最终目标的两种方法:

为每个用户使用真值。将数据库更改为以下内容:

{
    "root": {
        "account": {
            "ACC0001": {
                "id": "ACC0001",
                "create_day": "2020-04-20 16:56:11",
                "create_by": "USE001",
                "create_by_USE001": true,
                "create_by_USE002": false,
                "create_by_USE003": false,
                "create_by_USE004": false,
                "brief_name": "AAAAA",
                "status": "active"
            },
            "ACC0002": {
                "id": "ACC0002",
                "create_day": "2020-04-20 16:56:12",
                "create_by": "USE002",
                "create_by_USE001": false,
                "create_by_USE002": true,
                "create_by_USE003": false,
                "create_by_USE004": false,
                "brief_name": "BBBBB",
                "status": "inactive"
            },
  ...

更好的方法是使用firestore,因为它支持

您能否澄清您的预期输出是什么?您是想创建一个包含所有“create_by”的列表,还是想筛选到什么?谢谢@MyNameIsCaleb。我有一个用户列表['USE001'、'USE002'、'USE003'…],我想获得该列表中带有“create_by”的所有用户记录。在SQL中,我使用“从AAA中选择*,其中D='active'和(i='USE002'或i='USE003'或i='USE004'或i='USE005'),但在pyrebase中,我不知道如何查询?帮助我!!告诉我怎么做,谢谢@frunkad回答我的问题!如何使用此案例示例?我想让所有记录都具有“状态”=“不活动”,并且该记录为USE002、USE003、USE004。我不知道如何使用它是在上述方法(答案中提到的示例)还是在firestore中?