Repository navigation
Expand file tree
/
Copy pathstdDatabase_BackEnd.py
More file actions
48 lines (40 loc) · 1.75 KB
/
Copy pathstdDatabase_BackEnd.py
File metadata and controls
48 lines (40 loc) · 1.75 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
import sqlite3
#backends
def studentData():
con=sqlite3.connect("student.db")
cur=con.cursor()
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()