-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddDataToDatabase.py
53 lines (48 loc) · 1.36 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
53
import firebase_admin
from firebase_admin import credentials
from firebase_admin import db
cred = credentials.Certificate("serviceAccountKey.json") #path of the credential file
firebase_admin.initialize_app(cred,{
'databaseURL':"#"
})
ref = db.reference('Students')
data = {
"CSE21-073": {
"name": "Nikhil Shukla",
"department": "ComputerScience",
"starting_year": 2021,
"total_attendance": 2,
"section": "B1",
"year": 2,
"last_attendance_time": "2023-03-19 04:03:00"
},
"CSE21-113": {
"name": "Sudhanshu Chauhan",
"department": "ComputerScience",
"starting_year": 2021,
"total_attendance": 1,
"section": "B2",
"year": 2,
"last_attendance_time": "2023-03-19 04:03:00"
},
"CSE21-070": {
"name": "Mohit Maurya",
"department": "ComputerScience",
"starting_year": 2021,
"total_attendance": 1,
"section": "B1",
"year": 2,
"last_attendance_time": "2023-03-19 04:03:00"
},
"CSE21-072": {
"name": "Nikhil Sharma",
"department": "ComputerScience",
"starting_year": 2021,
"total_attendance": 3,
"section": "B1",
"year": 2,
"last_attendance_time": "2023-03-19 04:03:00"
}
}
for key,value in data.items():
ref.child(key).set(value)