-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddDataToDatabase.py
52 lines (43 loc) · 1.45 KB
/
AddDataToDatabase.py
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
import firebase_admin
from firebase_admin import credentials
from firebase_admin import db
# download the credential details .json file and save it to the same directory which this AddDataToDatabase.py exist.
cred = credentials.Certificate("serviceAccountKey.json")
firebase_admin.initialize_app(cred, {
'databaseURL': "#place your database URL here"
})
ref = db.reference('Students')
# Rename the student .png images by the corresponding ID which you provide below
# Customize the below json as your wish
data = {
"1": # add ID number which can uniquely identified the student
{
"name": "Pawan Pinsara",
"student_no": "CS/2020/xxx",
"major": "computer science",
"year": 2,
"last_attendance_time": "2022-12-11 00:23:40",
"total_attendance": 0,
},
"2":
{
"name": "name 2", # add a name here
"major": "---",
"student_no": "CS/2021/xxx",
"year": 4,
"last_attendance_time": "2022-12-11 00:34:34",
"total_attendance": 0,
},
"3":
{
"name": "name 2", # add a name here
"student_no": "CS/2020/xxx",
"major": "---",
"year": 2,
"last_attendance_time": "2022-12-11 01:54:34",
"total_attendance": 0,
},
}
for key, value in data.items():
ref.child(key).set(value)
print("data added to the database")