-
Notifications
You must be signed in to change notification settings - Fork 0
/
Insert.py
87 lines (62 loc) · 2.46 KB
/
Insert.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
80
81
82
83
84
85
86
87
import csv
import sqlite3
conn = sqlite3.connect("Attendance.db")
cursor = conn.cursor()
print("Connection successful ... ")
def insert_class():
with open ("Data\Classid.csv",'r') as file:
csv_reader = csv.reader(file)
i = 0
for rows in csv_reader:
print(rows[1],rows[2])
if i==0 :
i=2
else:
cursor.execute("""
insert into class (Year,Div) VALUES (?,?);
""",(rows[1],rows[2]))
def insert_student():
with open ("Data\Student.csv",'r') as file:
csv_reader = csv.reader(file)
i = 0
for rows in csv_reader:
print(rows[1],rows[2],rows[3])
if i==0 :
i=2
else:
cursor.execute("""
insert into student (Name,roll,cid) VALUES (?,?,?);
""",(rows[1],rows[2],rows[3]))
def insert_LectureCount():
with open ("Data\LectureCount.csv",'r') as file:
csv_reader = csv.reader(file)
i = 0
for rows in csv_reader:
print(rows[0],rows[1],rows[2],rows[3],rows[4])
if i==0 :
i=2
else:
cursor.execute("""
insert into lec_count (year,subject,a,b,c) VALUES (?,?,?,?,?);
""",(rows[0],rows[1],rows[2],rows[3],rows[4]))
def insert_attendance ():
cursor = conn.execute("""
select cid,sid from student;
""")
for rows in cursor:
print(rows[0],rows[1])
if rows[0]<=3 :
conn.execute("""
insert into SE (cid,sid,oop,dsa,deld,dm,coa) values (?,?,?,?,?,?,?)
""",(rows[0],rows[1],0,0,0,0,0))
elif rows[0]<=6:
conn.execute("""
insert into TE (cid,sid,cn,dbms,toc,isee,sepm) values (?,?,?,?,?,?,?)
""",(rows[0],rows[1],0,0,0,0,0))
else:
conn.execute("""
insert into BE (cid,sid,ai,e1,e2,comp,da) values (?,?,?,?,?,?,?)
""",(rows[0],rows[1],0,0,0,0,0))
print(" Inserted Sucessfully")
conn.commit()
conn.close()