-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddDataToDatabase.py
79 lines (74 loc) · 2.13 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import firebase_admin
from firebase_admin import credentials
from firebase_admin import db
from tkinter import messagebox
cred = credentials.Certificate("serviceAccountKey.json")
firebase_admin.initialize_app(cred,{
'databaseURL':"https://faceattendancerealtime2-b14d6-default-rtdb.firebaseio.com/"
})
ref = db.reference('Students')
data = {
"578942":
{
"name": "Lokesh T",
"major": "Computer-BCA",
"starting_year": 2018,
"total_attendance": 6,
"standing": "A",
"year": 4,
"last_attendance_time": "2022-12-11 00:45:34"
},
"321654":
{
"name": "Murtaza Hassan",
"major": "Robotics",
"starting_year":2017,
"total_attendance":6,
"standing": "G",
"year": 5,
"last_attendance_time": "2022-12-11 00:54:34"
},
"852741":
{
"name": "Emly Blunt",
"major": "Economics",
"starting_year":2021,
"total_attendance":12,
"standing": "B",
"year": 1,
"last_attendance_time": "2022-12-11 00:54:34"
},
"425486":
{
"name": "Kalam",
"major": "Rocket Science",
"starting_year": 2019,
"total_attendance": 7,
"standing": "A",
"year": 4,
"last_attendance_time": "2022-12-11 00:45:34"
},
"678426":
{
"name": "Ranganath",
"major": "Principal",
"starting_year": 2017,
"total_attendance": 7,
"standing": "A",
"year": 6,
"last_attendance_time": "2022-12-11 00:45:34"
},
"963852":
{
"name": "Elon Musk",
"major": "Space X",
"starting_year":2020,
"total_attendance":7,
"standing": "G",
"year": 2,
"last_attendance_time": "2022-12-11 00:54:34"
}
}
for key,value in data.items():
ref.child(key).set(value)
messagebox.showinfo('Add To Database', 'Thank You ! Data Successfully Added')