-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudent_db_backend.py
More file actions
36 lines (30 loc) · 1.14 KB
/
Copy pathstudent_db_backend.py
File metadata and controls
36 lines (30 loc) · 1.14 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
import sqlite3
def studentData(): #this function creates the database ith all the parameters
con= sqlite3.connect("student.db") #this line creates a connection with the student.db database
cur= con.cursor()
cur.execute("CREATE TABLE IF NOT EXIST student(id INTEGER PRIMARY KEY, stdID, Firstname text, Surname text, DoB text, \
Age text, Gender text, Address text, Mobile, text)")
con.commit()
con.close()
def addStdRec(stdID, Firstname, Surname, DoB, Age, Gender, Address, Mobile):
con = sqlite3.connect("student.db")
cur = con.cursor()
cur.execute("INSERT INTO student VALUES(NULL,?,?,?,?,?,?,?,?", \
(stdID, Firstname, Surname, DoB, Age, Gender, Address, Mobile))
con.commit()
con.close()
return rows
def vieData():
con = sqlite3.connect("student.db")
cur = con.cursor()
cur.execute("SELECT * FROM student")
rows = cur.fetchall()
con.close()
return rows
def deleteRec():
con = sqlite3.connect("student.db")
cur = con.cursor()
cur.execute("DELETE FROM student WHERE id=?", (id,))
con.commit()
con.close()
studentData()