-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddDataToDatabase.py
50 lines (46 loc) · 1.42 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
# Imported from Project Settings> Services Accout> Python
import firebase_admin
from firebase_admin import credentials
from firebase_admin import db
cred = credentials.Certificate("serviceAccountKey.json")
# Realtime Database URL is placed in JSON format
firebase_admin.initialize_app(cred, {
'databaseURL' : "https://faceattendancerealtime-179d4-default-rtdb.asia-southeast1.firebasedatabase.app/"
})
# We are creating Employees Database
ref = db.reference('Employees')
data = {
"076412":
{
"name" : "Biplav Poudel",
"position" : "Secretary",
"starting_year" : 2080,
"total_attendance" : 10,
"rank" : "A",
"year": 1,
"last_attendance_time" : "2023-05-27 10:54:34"
},
"321654":
{
"name": "Salina Gurung",
"position": "Section Officer",
"starting_year": 2080,
"total_attendance": 1,
"rank" : "C",
"year": 1,
"last_attendance_time": "2023-05-28 12:49:30"
},
"852741":
{
"name": "Yogesh Bhandari",
"position": "Office Assistant",
"starting_year": 2080,
"rank" : "B",
"total_attendance": 4,
"year": 1,
"last_attendance_time": "2023-05-28 13:34:01"
}
}
# For storing the data
for key, value in data.items():
ref.child(key).set(value)