-
Notifications
You must be signed in to change notification settings - Fork 0
/
Library_Backend.py
76 lines (53 loc) · 3.2 KB
/
Library_Backend.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
import sqlite3
def connect():
con = sqlite3.connect('library.db')
cur = con.cursor()
cur.execute('CREATE TABLE IF NOT EXISTS library(x INTEGER PRIMARY KEY, Mtype text, refno integer, fname text, \
surname text, address text, post integer, mobno integer, ID text, title text, author text, \
borrow integer, due integer, loan integer)')
con.commit()
con.close()
def insert(Mtype = ' ', refno = ' ', fname = ' ', surname = ' ', address = ' ', post = ' ', mobno = ' ', ID = ' ', \
title = ' ', author = ' ', borrow = ' ', due = ' ', loan = ' '):
con = sqlite3.connect('library.db')
cur = con.cursor()
cur.execute('INSERT INTO library VALUES (NULL,?,?,?,?,?,?,?,?,?,?,?,?,?)',(Mtype,refno,fname,surname,address,post, \
mobno,ID,title,author,borrow,due,loan))
con.commit()
con.close()
def view():
con = sqlite3.connect('library.db')
cur = con.cursor()
cur.execute('SELECT * FROM library')
row = cur.fetchall()
return row
con.close()
def delete(x):
con = sqlite3.connect('library.db')
cur = con.cursor()
cur.execute('DELETE FROM library WHERE x = ?',(x,))
con.commit()
con.close()
def update(x, Mtype = ' ', refno = ' ', fname = ' ', surname = ' ', address = ' ', post = ' ', mobno = ' ', ID = ' ', \
title = ' ', author = ' ', borrow = ' ', due = ' ', loan = ' '):
con = sqlite3.connect('library.db')
cur = con.cursor()
cur.execute('UPDATE library SET Mtype = ? OR refno = ? OR fname = ? OR surname = ? OR address = ? OR post = ? OR \
mobno = ? OR ID = ? OR title = ? OR author = ? OR borrow = ? OR due = ? OR loan = ?',(Mtype,refno,fname,surname,address, \
post,mobno,ID,title,author,borrow,due,loan))
con.commit()
con.close()
def search(Mtype = ' ', refno = ' ', fname = ' ', surname = ' ', address = ' ', post = ' ', mobno = ' ', ID = ' ', \
title = ' ', author = ' ', borrow = ' ', due = ' ', loan = ' '):
con = sqlite3.connect('library.db')
cur = con.cursor()
cur.execute('SELECT * FROM library WHERE Mtype = ? OR refno = ? OR fname = ? OR surname = ? OR address = ? OR \
post = ? OR mobno = ? OR ID = ? OR title = ? OR author = ? OR borrow = ? OR due = ? OR loan = ?',(Mtype,refno,\
fname,surname,\
address,post,mobno,\
ID,title,author,\
borrow,due,loan))
row = cur.fetchall()
return row
con.close()
connect()