-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstdDatabase.py
More file actions
54 lines (48 loc) · 1.89 KB
/
stdDatabase.py
File metadata and controls
54 lines (48 loc) · 1.89 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
import sqlite3
#backend
def studentData():
con=sqlite3.connect("student.db")
cur.execute("CREATE TABLE IF NOT EXISTS student \
(id INTEGER PRIMARY key, \
StdID text, \
Firstname text, \
Lastname text, \
DoB text, \
Age text, \
Gender text, \
Address text, \
Mobile text")
con.commit()
con.close()
def addStdRec(StdID, Firstname, Lastname, DoB, Age, Gender, Address, Mobile):
con=sqlite3.connect("student.db")
cur=con.cursor(*)
cur.execute("INSERT INTO student VALUES (NULL, ?, ?, ? , ?, ?, ?, ?)", (StdID, Firstname, Lastname, DoB, Age, Gender, Address, Mobile))
con.commit()
con.close()
def viewData():
con=sqlite3.connect("student.db")
cur=con.cursor()
cur.execute("SELECT * FROM student")
rows=cur.fetchall()
con.close
return rows
def deleteRec(id):
con=sqlite3.connect("student.db")
cur=con.cursor()
cur.execute("DELETE FROM student WHERE id=?", (id,))
con.commit()
con.close
def searchData(StdID="", Firstname="", Lastname="", DoB="", Age="", Gender="", Address="", Mobile=""):
con=sqlite3.connect("student.db")
cur=con.cursor()
cur.execute("SELECT * FROM student WHERE StdID=? OR Firstname=? OR Lastname=? OR DoB=? OR Age=? OR Gender=? OR Address=? OR Mobile=?", (StdID, Firstname, Lastname, DoB, Age, Gender, Address, Mobile))
rows=cur.fetchall()
con.close()
return rows
def dataUpdate(StdID="", Firstname="", Lastname="", DoB="", Age="", Gender="", Address="", Mobile=""):
con=sqlite3.connect("student.db")
cur=con.cursor()
cur.execute("UPDATE student SET StdID=?, Firstname=?, Lastname=?, DoB=?, Age=?, Gender=?, Address=?, Mobile=?, WHERE id=?", (StdID, Firstname, Lastname, DoB, Age, Gender, Address, Mobile, id))
con.commit()
con.close()