-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfunc.py
More file actions
55 lines (47 loc) · 1.59 KB
/
func.py
File metadata and controls
55 lines (47 loc) · 1.59 KB
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
#!usr/env/bin/python2.7
import sqlite3
import datetime
def take_attendance(strength,course,conn_obj):
today = str(datetime.date.today())
print ("Attendance for %s" %today)
try:
conn_obj.execute("ALTER TABLE %s ADD COLUMN '%s' 'char'" %(course,today))
except sqlite3.OperationalError:
print "Attendance for the date already taken"
return
print "Enter p | a | m for Present | Absent | Manual_entry"
for x in range(1,strength):
print ("%d." %x)
att = raw_input("").lower()
while(1):
if att =='p' :
print "present"
conn_obj.execute("UPDATE %s SET '%s'='P' WHERE 'roll'=%d" %(course,today,x))
break
elif att == 'a' :
print "absent"
conn_obj.execute("UPDATE %s SET '%s'='A' WHERE 'roll'=%d" %(course,today,x))
break
elif att == 'm' :
man = int(raw_input("Enter the roll call\n"))
man_att = raw_input("Enter p | a for Present | Absent\n").lower()
if man_att == 'p' :
print "present"
conn_obj.execute("UPDATE %s SET '%s'='P' WHERE 'roll'=%d" %(course,today,man))
elif man_att == 'a' :
print "absent"
conn_obj.execute("UPDATE %s SET '%s'='A' WHERE 'roll'=%d" %(course,today,man))
break
else:
print "Enter a valid input"
continue
def course_exist(course,conn_obj):
for x in conn_obj.execute("SELECT name from courses;"):
if (x[0].lower()) == (course.lower()):
return True
return False
def create_course(course,strength,conn_obj):
conn_obj.execute('CREATE TABLE %s(roll int);' %course)
for x in range(1,strength):
conn_obj.execute("INSERT INTO %s VALUES(%d);" %(course,x))
if __name__ == "__main__":main()