-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirebase_db.py
More file actions
54 lines (34 loc) · 803 Bytes
/
firebase_db.py
File metadata and controls
54 lines (34 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from init_firebase import firebase
import json
db = firebase.database()
def put_request_data(tag,data):
if tag and data:
db.child(tag).push(data)
def get_request_data(tag):
if tag:
queries = db.child(tag).get()
return queries
def update_data(id_tag,tag,data):
queries = get_request_data(tag).val()
response = {}
for k,v in queries.items():
if k == id_tag:
response[k] = v
break
if response:
response[k]['response'] = data
db.child(tag).update(response)
else:
return None
#tag = "queries"
#id_tag = "-L_6L3Op4SXqvdt2TCAl"
#data = "This is nice"
#json_dict = json.dumps(data)
#update_data(id_tag,tag,data)
'''
queries = get_request_data("queries")
data = queries.val()
for v in data.items():
#print("Key is {}".format(k))
print("Value is {}".format(v))
'''