-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmongoRead.py
More file actions
40 lines (32 loc) · 935 Bytes
/
mongoRead.py
File metadata and controls
40 lines (32 loc) · 935 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
from pymongo import MongoClient
client = MongoClient(
"mongodb+srv://anupamAdmin:anupamAdmin@cluster0.2c2zj.mongodb.net/student_db")
db = client.get_database("student_db")
records = db.get_collection("student_records")
records.count_documents({})
def findBool(number, date):
flag = 0
found = records.find({})
for i in found:
# print(i)
if(i["Enrollment_No"] == number and i["Date"] == date):
flag = 1
break
else:
flag = 0
continue
if flag:
return True
return False
def insert(name, number, date, time):
if findBool(number=number, date=date):
print("Attendance marked")
else:
new_Attendance = {
"Enrollment_No": number,
"Name": name,
"Date": date,
"Time": time
}
records.insert_one(new_Attendance)
print("New attendance taken")