-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmarks.py
29 lines (28 loc) · 926 Bytes
/
marks.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
import pandas as pd
import sqlite3
connection = sqlite3.connect('marks.db')
cursor = connection.cursor()
table = "CREATE TABLE marks(Name VARCHAR(255),RollNo INT,Date DATE,Subject VARCHAR(255),Marks INT)"
try:
cursor.execute(table)
except:
exit
def store_marks(path):
file = pd.read_csv(path)
for i in range(len(file['Name'])):
name = file['Name'][i]
roll = file['Roll No'][i]
date = file['Date'][i]
subject = file['Subject'][i]
marks = file['Marks'][i]
command = "SELECT * FROM marks WHERE Name='"+name+"'"
cursor.execute(command)
res = cursor.fetchall()
# print(res[0][2])
# if(res[0]==[]):
com = "INSERT INTO marks VALUES('"+name+"','"+str(roll)+"','"+str(date)+"','"+subject+"','"+str(marks)+"')"
cursor.execute(com)
# else:
# exit
# print(res[0][2]==date)
connection.commit()