下午好。我在firebase中具有以下结构:
{
"4d6a58279b404999a29535b956ad6965" : {
"cpu_temp" : "52000",
"gpu_temp" : "51000",
"internet_ip" : "189.210.183.17",
"ipaddr" : "192.168.1.101",
"last_response" : "2019-07-11 14:27:26",
"mac_add" : "50:3e:aa:af:49:bf",
"terminal" : {
"-LjX3T42e7T3tXgtbCXg" : {
"comando" : "ls",
"dt_comando" : "2019-02-07 09:06:45",
"processado" : "0",
"resposta" : "aW5zdGFsbC5zaAo=",
"timeout" : "5"
},
"-LjX3Tjhkhkjhkkjh8yh" : {
"comando" : "cat teste.txt",
"dt_comando" : "2019-02-07 09:06:45",
"processado" : "1",
"resposta" : "aW5zdGFsbC5zaAo=",
"timeout" : "5"
}
}
}
}
我需要进行以下查询:
仅列出terminal
值为processado
0
结构中最早的命令
我这样做如下:
t = db.child("iots").child(iotId).child("terminal").order_by_child("processado").equal_to("0").get()
它返回以下错误
t = db.child("iots").child(iotId).child("terminal").order_by_child("processado").equal_to(0).get()
File "/usr/local/lib/python3.7/dist-packages/pyrebase/pyrebase.py", line 264, in get
raise_detailed_error(request_object)
File "/usr/local/lib/python3.7/dist-packages/pyrebase/pyrebase.py", line 448, in raise_detailed_error
raise HTTPError(e, request_object.text)
requests.exceptions.HTTPError: [Errno 400 Client Error: Bad Request for url: https://XXXX-admiot.firebaseio.com/iots/4d6a58279b404999a29535b956ad6965/terminal.json?orderBy=%2522processado%2522&equalTo=0] {
"error" : "orderBy must be a valid JSON encoded path"
}
有人可以帮助我使用PyreBase执行此查询吗? 我正在使用python 3.7
现在我用此代码进行了修复:
def noquote(s):
return s
pyrebase.pyrebase.quote = noquote
和命令行上的新错误:
{
"error" : "Index not defined, add \".indexOn\": \"processado\", for path \"/iots/4d6a58279b404999a29535b956ad6965/terminal\", to the rules"
}