Introduction To The Project Library Management System
Introduction To The Project Library Management System
OBJECTIVES OF PROJECT ON
LIBRARY MANAGEMENT SYSTEM
The main objective of the project on Library Management System is
to manage the details of Student, Books, Issues, Librarian Member. It
manages all the information about Student, Address, Member,
Student. The project is totally built at administrative end and thus
only the administrator is guaranteed the access. The purpose of the
project is to built an application program to reduce the manual work
for managing the Student, Books, Address, Issues. It tracks all the
details about the Issues, Librarian, Member.
FUNCTIONALITIES PROVIDED BY
LIRBRARY MANAGEMENT SYSTEM
Provides the searching facilities based on various factors. Such
as Student, Issues, Librarian, Member.
Library Management System also manage the Address details
online for Librarian details, Member details, Student.
Tracks all the information of Books, Address, Librarian etc.
Manage the information of Books.
Shows the information and description of the Student, Issues.
To increase efficiency of managing the Student, Books.
Deals with monitoring the information and transactions of the
Librarian.
Manage the information of Student as well as Librarian.
Editing, adding and updating of records is improved which
results in proper research management of Student data.
Integration of all records of Member.
REPORTS OF LIBRARY
MANAGEMENT SYSTEM
1. It generates the report on Students, Books, Address.
2. Provides filter reports on Issues, Librarian, Member.
3. You can easily export the report PDF for the Student, Address,
Librarian.
4. Application also provides Excel export for Books, Issues, Member.
5. You can also export the report into csv format for Student, Books,
Member.
MODULES OF LIBRARY
MANAGEMENT SYSTEM
Student Management Module: Used for managing the student
details.
Member Module: Used for managing the details of Member.
Address Module: Used for managing the details of Address.
Books Management Module: Used for managing the
information and details of the Books.
Issues Module: Used for managing the Issues details.
Librarian Module: Used for managing the Librarian
management.
Login Module: Used for managing the Login details.
Users Module: Used for managing the Users of the system.
FEASIBILITY STUDY
After doing the project Library Management System, study and
analyzing all the existing or required functionalities of the system, the
next task is to do the feasibility study for the project. All projects are
feasible- given unlimited resources and infinite time.
Feasibility study includes consideration of all the possible ways to
provide a solution to the given problem. The proposed solution should
satisfy all the user requirements and should be flexible enough so that
future changes can be easily done based on the future upcoming
requirements.
A. Economic Feasibility
This is a very important aspect to be considered while developing a
project. We decided the technology based on minimum possible cost
factor.
All hardware and software cost has to be borne by the
organization
Overall, we have estimated that the benefits the organization is
going to receive from the proposed system will surely overcome
the initial cost and the later on running cost for system.
B. Technical feasibility
This includes the study of function, performance and constraints that
may affect the ability to achieve an acceptable system. For this
feasibility study, we studied complete functionality to be provided in
the system, as described in the System Requirement Specification
(SRS), and checked if everything was possible using different type of
frontend and backend platforms.
C. Operational Feasibility
No doubt the proposed system is fully GUI based that is very user
friendly and all inputs to be taken all self-explanatory even to a
layman. Decides, a proper training has been conducted to let know the
essence of the system to the users so that they feel comfortable with
new system. As far our study is concerned the clients are comfortable
and happy as the system has cutdown their loads and doing.
BENEFIT TO ORGANISATION –
The organization will obviously be able to gain benefits such as
savings in operating costs, reduction in paper work, better utilization
of human resources and more presentable image increasing goodwill.
PROJECT CATEGORY –
Relational Database Management System (RDBMS): This is an
RDBMS based project which is currently using MySQL for all the
transaction statements. MySQL is an open-source RDBMS system.
System analysis
System analysis is the process of gathering and interpreting facts,
diagnosing problems and the information about the Library
Management System to recommend improvements in the system. It is
a problem-solving activity that requires intensive communication
between the system users and the system developers. System analysis
or study is an important phase of any system development process.
The system is studied to the minutest detail and analyzed. The system
analyst plays the role of the interrogator and dwells deep into the
working of the present system. The system is viewed as a whole and
the input to the system are identified. The outputs from the
organizations are traced to the various processes. System analysis is
concerned with becoming aware of the problem, identifying the
relevant and decisional variables, analyzing and synthesizing the
various factors and determining an optimal or at least a satisfactory
solution or program of action. A detailed study of the process must be
made by various techniques like interviews, questionnaires etc. the
data collected by these sources must be scrutinized to arrive to a
conclusion. The conclusion is an understanding of how the system
functions. This system is called the existing system. Now, the existing
system is subjected to close study and problem areas are identified.
The designer now functions as a problem solver and tries to sort out
the difficulties that the enterprise faces. The solutions are given as
proposals. The proposal is then weighed with the existing system
analytically and the best one is selected. The proposal is presented to
the user for an endorsement by the user. The proposal is reviewed on
user request and suitable changes are made. This is loop that ends as
soon as the user is satisfied with the proposal. It does various
feasibility studies. In these studies, a rough figure of the system
activities can be obtained from which the decision about the strategies
to be followed for effective system study and analysis can be taken.
CODING -
MODULE FOR LOGIN PAGE OF THE SYSTEM –
from tkinter import *
from tkinter import messagebox
import os
import mysql.connector
from mysql.connector import Error
py=sys.executable
#creating window
class Lib(Tk):
def _init_(self):
super()._init_()
self.a = StringVar()
self.b = StringVar()
self.maxsize(1200, 700)
self.minsize(1200, 700)
self.configure(bg="gray")
self.title("LIBRARY MANAGEMENT SYSTEM")
#verifying input
def chex():
if len(self.user_text.get()) < 0:
messagebox.showinfo(" INVALID USERNAME OR PASSWORD" )
elif len(self.pass_text.get()) < 0:
messagebox.showinfo(" INVALID USERNAME OR PASSWORD")
else:
try:
conn = mysql.connector.connect(host='localhost',
database='library',
user='root',
password='')
cursor = conn.cursor()
user = self.user_text.get()
password = self.pass_text.get()
cursor.execute('Select * from `admin` where user= %s AND
password = %s ',(user,password,))
pc = cursor.fetchone()
if pc:
self.destroy()
os.system('%s %s' % (py, 'options.py'))
else:
print(pc)
messagebox.showinfo('Error', 'Username and password not
found')
self.user_text.delete(0, END)
self.pass_text.delete(0, END)
except Error:
messagebox.showinfo('Error',"Something Goes Wrong,Try
restarting")
def check():
Lib().mainloop()
MAIN MODULE OF THE PROJECT –
import mysql.connector
from mysql.connector import Error
py=sys.executable
#creating window
class MainWin(Tk):
def _init_(self):
super()._init_()
self.iconbitmap(r'libico.ico')
self.configure(bg='gray')
self.canvas = Canvas(width=1366, height=768, bg='gray')
self.canvas.pack()
self.maxsize(1320, 768)
self.minsize(1320,768)
self.state('zoomed')
self.title('LIBRARY MANAGEMENT SYSTEMS')
self.a = StringVar()
self.b = StringVar()
self.mymenu = Menu(self)
#calling scripts
def a_s():
os.system('%s %s' % (py, 'Add_Student.py'))
def a_b():
os.system('%s %s' % (py, 'Add_Books.py'))
def r_b():
os.system('%s %s' % (py, 'remove_book.py'))
def r_s():
os.system('%s %s' % (py, 'Remove_student.py'))
def ib():
os.system('%s %s' % (py, 'issueTable.py'))
def ret():
os.system('%s %s' % (py, 'ret.py'))
def sea():
os.system('%s %s' % (py,'Search.py'))
def log():
conf = messagebox.askyesno("Confirm", "Are you sure you want to
Logout?")
if conf:
self.destroy()
os.system('%s %s' % (py, 'Main.py'))
# def handle(event):
# if self.listTree.identify_region(event.x,event.y) == "separator":
# return "break"
def add_user():
os.system('%s %s' % (py, 'Reg.py'))
def rem_user():
os.system('%s %s' % (py, 'Rem.py'))
def sest():
os.system('%s %s' % (py,'Search_Student.py'))
#creating table
self.listTree = ttk.Treeview(self,height=14,columns=('Student','Book','Issue
Date','Return Date'))
self.vsb =
ttk.Scrollbar(self,orient="vertical",command=self.listTree.yview)
self.hsb =
ttk.Scrollbar(self,orient="horizontal",command=self.listTree.xview)
self.listTree.configure(yscrollcommand=self.vsb.set,xscrollcommand=self.hsb.s
et)
self.listTree.heading("#0", text='ID')
self.listTree.column("#0", width=50,minwidth=50,anchor='center')
self.listTree.heading("Student", text='Student')
self.listTree.column("Student", width=200, minwidth=200,anchor='center')
self.listTree.heading("Book", text='Book')
self.listTree.column("Book", width=200, minwidth=200,anchor='center')
self.listTree.heading("Issue Date", text='Issue Date')
self.listTree.column("Issue Date", width=125,
minwidth=125,anchor='center')
self.listTree.heading("Return Date", text='Return Date')
self.listTree.column("Return Date", width=125, minwidth=125,
anchor='center')
self.listTree.place(x=320,y=360)
self.vsb.place(x=1028,y=361,height=287)
self.hsb.place(x=320,y=650,width=700)
ttk.Style().configure("Treeview",font=('Times new Roman',15))
list1 = Menu(self)
list1.add_command(label="Student", command=a_s)
list1.add_command(label="Book", command=a_b)
list3 = Menu(self)
list3.add_command(label = "Add User",command = add_user)
list3.add_command(label = "Remove User",command = rem_user)
self.mymenu.add_cascade(label='Add', menu=list1)
self.mymenu.add_cascade(label = 'Admin Tools', menu = list3)
self.config(menu=self.mymenu)
def ser():
if(len(self.studid.get())==0):
messagebox.showinfo("Error", "Empty Field!")
else:
try:
conn = mysql.connector.connect(host='localhost',
database='library',
user='root',
password='')
cursor = conn.cursor()
change = int(self.studid.get())
cursor.execute("Select
bi.issue_id,s.name,b.name,bi.issue_date,bi.return_date from issue_book
bi,student s,book b where s.stud_id = bi.stud_id and b.book_id = bi.book_id and
s.stud_id = %s",[change])
pc = cursor.fetchall()
if pc:
self.listTree.delete(*self.listTree.get_children())
for row in pc:
self.listTree.insert("",'end',text=row[0] ,values =
(row[1],row[2],row[3],row[4]))
else:
messagebox.showinfo("Error", "Either ID is wrong or The book is
not yet issued on this ID")
except Error:
#print(Error)
messagebox.showerror("Error","Something Goes Wrong")
def ent():
if (len(self.bookid.get()) == 0):
messagebox.showinfo("Error", "Empty Field!")
else:
try:
self.conn = mysql.connector.connect(host='localhost',
database='library',
user='root',
password='')
self.myCursor = self.conn.cursor()
book = int(self.bookid.get())
self.myCursor.execute("Select
bi.issue_id,s.name,b.name,bi.issue_date,bi.return_date from issue_book
bi,student s,book b where s.stud_id = bi.stud_id and b.book_id = bi.book_id and
b.book_id = %s",[book])
self.pc = self.myCursor.fetchall()
if self.pc:
self.listTree.delete(*self.listTree.get_children())
for row in self.pc:
self.listTree.insert("", 'end',
text=row[0],values=(row[1], row[2], row[3],
row[4]))
else:
messagebox.showinfo("Error", "Either ID is wrong or The book is
not yet issued")
except Error:
messagebox.showerror("Error", "Something Goes Wrong")
def check():
try:
conn = mysql.connector.connect(host='localhost',
database='library',
user='root',
password='')
mycursor = conn.cursor()
mycursor.execute("Select * from admin")
z = mycursor.fetchone()
if not z:
messagebox.showinfo("Error", "Please Register A user")
x = messagebox.askyesno("Confirm","Do you want to register a
user")
if x:
self.destroy()
os.system('%s %s' % (py, 'Reg.py'))
else:
#label and input box
self.label3 = Label(self, text='LIBRARY MANAGEMENT
SYSTEM',fg='black',bg="gray" ,font=('Courier new', 30, 'bold'))
self.label3.place(x=350, y=22)
self.label4 = Label(self, text="ENTER STUDENT",bg="gray",
font=('Courier new', 18, 'bold'))
self.label4.place(x=130, y=107)
self.studid = Entry(self, textvariable=self.a, width=90)
self.studid.place(x=405, y=110)
self.srt = Button(self, text='Search', width=15, font=('arial',
10),command = ser).place(x=1000, y=106)
self.label5 = Label(self, text="ENTER THE BOOK ID",bg="gray",
font=('Courier new', 18, 'bold'))
self.label5.place(x=75, y=150)
self.bookid = Entry(self, textvariable=self.b, width=90)
self.bookid.place(x=405, y=160)
self.brt = Button(self, text='Find', width=15, font=('arial',
10),command = ent).place(x=1000, y=150)
self.label6 = Label(self, text="INFORMATION
DETAILS",bg="gray", font=('Courier new', 15, 'underline', 'bold'))
self.label6.place(x=560, y=300)
self.button = Button(self, text='Search Student', width=25,
font=('Courier new', 10), command=sest).place(x=240,y=250)
self.button = Button(self, text='Search Book', width=25,
font=('Courier new', 10), command=sea).place(x=520,y=250)
self.brt = Button(self, text="Issue Book", width=15, font=('Courier
new', 10), command=ib).place(x=800, y=250)
self.brt = Button(self, text="Return Book", width=15,
font=('Courier new', 10), command=ret).place(x=1000, y=250)
self.brt = Button(self, text="LOGOUT", width=15,bg="red",
font=('Courier new', 10), command=log).place(x=1150, y=105)
except Error:
messagebox.showerror("Error", "Something Goes Wrong")
check()
MainWin().mainloop()
class Search(Tk):
def _init_(self):
super()._init_()
f = StringVar()
g = StringVar()
self.title("Search Student")
self.maxsize(800,520)
self.canvas = Canvas(width=1366, height=768, bg='gray')
self.canvas.pack()
self.iconbitmap(r'libico.ico')
l1=Label(self,text="Search Student",bg='gray', font=("Courier
new",20,'bold')).place(x=290,y=40)
l = Label(self, text="Search By",bg='gray', font=("Courier new", 15,
'bold')).place(x=180, y=100)
def insert(data):
self.listTree.delete(*self.listTree.get_children())
for row in data:
self.listTree.insert("","end",text = row[0], values =
(row[1],row[2],row[3]))
def ge():
if (len(self.entry.get())) == 0:
messagebox.showinfo('Error', 'First select a item')
elif (len(self.combo.get())) == 0:
messagebox.showinfo('Error', 'Enter the '+self.combo.get())
elif self.combo.get() == 'Name':
try:
self.conn = mysql.connector.connect(host='localhost',
database='library',
user='root',
password='')
self.mycursor = self.conn.cursor()
name = self.entry.get()
self.mycursor.execute("Select * from student where name like
%s",['%'+name+'%'])
pc = self.mycursor.fetchall()
if pc:
insert(pc)
else:
messagebox.showinfo("Oop's","Name not found")
except Error:
messagebox.showerror("Error", "Something goes wrong")
elif self.combo.get() == 'ID':
try:
self.conn = mysql.connector.connect(host='localhost',
database='library',
user='root',
password='')
self.mycursor = self.conn.cursor()
id = self.entry.get()
self.mycursor.execute("Select * from student where stud_id like
%s", ['%' + id + '%'])
pc = self.mycursor.fetchall()
if pc:
insert(pc)
else:
messagebox.showinfo("Oop's", "Id not found")
except Error:
messagebox.showerror("Error", "Something goes wrong")
self.b= Button(self,text="Find",width=8,font=("Courier
new",8,'bold'),command= ge )
self.b.place(x=400,y=170)
self.combo=ttk.Combobox(self,textvariable=g,values=["Name","ID"],widt
h=40,state="readonly")
self.combo.place(x = 310, y = 105)
self.entry = Entry(self,textvariable=f,width=43)
self.entry.place(x=310,y=145)
self.la = Label(self, text="Enter",bg = 'gray', font=("Courier new", 15,
'bold')).place(x=180, y=140)
def handle(event):
if self.listTree.identify_region(event.x,event.y) == "separator":
return "break"
self.listTree = ttk.Treeview(self, height=13,columns=('Student Name',
'Phone Number', 'Address'))
self.vsb =
ttk.Scrollbar(self,orient="vertical",command=self.listTree.yview)
self.listTree.configure(yscrollcommand=self.vsb.set)
self.listTree.heading("#0", text='Student ID', anchor='w')
self.listTree.column("#0", width=100, anchor='w')
self.listTree.heading("Student Name", text='Student Name')
self.listTree.column("Student Name", width=200, anchor='center')
self.listTree.heading("Phone Number", text='Phone Number')
self.listTree.column("Phone Number", width=200, anchor='center')
self.listTree.heading("Address", text='Address')
self.listTree.column("Address", width=200, anchor='center')
self.listTree.place(x=40, y=200)
self.vsb.place(x=743,y=200,height=287)
ttk.Style().configure("Treeview", font=('Times new Roman', 15))
Search().mainloop()
MODULE FOR BOOK INFORMATION –
from tkinter import *
from tkinter import ttk
from tkinter import messagebox
import mysql.connector
from mysql.connector import Error
class Search(Tk):
def _init_(self):
super()._init_()
f = StringVar()
g = StringVar()
self.title("Search Book")
self.maxsize(800,500)
self.minsize(800,500)
self.canvas = Canvas(width=800, height=500, bg='gray')
self.canvas.pack()
self.iconbitmap(r'libico.ico')
l1=Label(self,text="Search Library",bg='gray', font=("Courier
new",20,'bold')).place(x=290,y=20)
l = Label(self, text="Search By",bg='gray', font=("Courier new", 15,
'bold')).place(x=60, y=96)
def insert(data):
self.listTree.delete(*self.listTree.get_children())
for row in data:
self.listTree.insert("", 'end', text=row[0], values=(row[1],
row[2], row[3]))
def ge():
if (len(g.get())) == 0:
messagebox.showinfo('Error', 'First select a item')
elif (len(f.get())) == 0:
messagebox.showinfo('Error', 'Enter the '+g.get())
elif g.get() == 'Book Name':
try:
self.conn = mysql.connector.connect(host='localhost',
database='library',
user='root',
password='')
self.mycursor = self.conn.cursor()
self.mycursor.execute("Select * from book where name LIKE
%s",['%'+f.get()+'%'])
self.pc = self.mycursor.fetchall()
if self.pc:
insert(self.pc)
else:
messagebox.showinfo("Oop's","Either Book Name is incorrect
or it is not available")
except Error:
messagebox.showerror("Error","Something goes wrong")
elif g.get() == 'Author Name':
try:
self.conn = mysql.connector.connect(host='localhost',
database='library',
user='root',
password='')
self.mycursor = self.conn.cursor()
self.mycursor.execute("Select * from book where author LIKE
%s", ['%'+f.get()+'%'])
self.pc = self.mycursor.fetchall()
if self.pc:
insert(self.pc)
else:
messagebox.showinfo("Oop's","Author Name not found")
except Error:
messagebox.showerror("Error","Something goes wrong")
elif g.get() == 'Book Id':
try:
self.conn = mysql.connector.connect(host='localhost',
database='library',
user='root',
password='')
self.mycursor = self.conn.cursor()
self.mycursor.execute("Select * from book where book_id LIKE
%s", ['%'+f.get()+'%'])
self.pc = self.mycursor.fetchall()
if self.pc:
insert(self.pc)
else:
messagebox.showinfo("Oop's","Either Book Id is incorrect or it
is not available")
except Error:
messagebox.showerror("Error","Something goes wrong")
b=Button(self,text="Find",width=15,bg='gray',font=("Courier
new",10,'bold'),command=ge).place(x=460,y=148)
c=ttk.Combobox(self,textvariable=g,values=["Book Name","Author
Name","Book Id"],width=40,state="readonly").place(x = 180, y = 100)
en = Entry(self,textvariable=f,width=43).place(x=180,y=155)
la = Label(self, text="Enter",bg='gray', font=("Courier new", 15,
'bold')).place(x=100, y=150)
def handle(event):
if self.listTree.identify_region(event.x,event.y) == "separator":
return "break"
Search().mainloop()
#creating window
class Add(Tk):
def _init_(self):
super()._init_()
self.iconbitmap(r'libico.ico')
self.maxsize(500,417)
self.minsize(500,417)
self.title('Add Student')
self.canvas = Canvas(width=500, height=417, bg='gray')
self.canvas.pack()
n = StringVar()
p = StringVar()
a = StringVar()
#verifying input
def asi():
if len(n.get()) < 1:
messagebox.showinfo("Oop's", "Please Enter Your Name")
elif len(p.get()) < 1:
messagebox.showinfo("Oop's","Please Enter Your Phone Number")
elif len(a.get()) < 1:
messagebox.showinfo("Oop's", "Please Enter Your Address")
else:
try:
self.conn = mysql.connector.connect(host='localhost',
database='library',
user='root',
password='')
self.myCursor = self.conn.cursor()
name1 = n.get()
pn1 = p.get()
add1 = a.get()
self.myCursor.execute("Insert into
student(name,phone_number,address) values (%s,%s,
%s)",[name1,pn1,add1])
self.conn.commit()
messagebox.showinfo("Done","Student Inserted Successfully")
ask = messagebox.askyesno("Confirm","Do you want to add
another student?")
if ask:
self.destroy()
os.system('%s %s' % (py, 'Add_Student.py'))
else:
self.destroy()
self.myCursor.close()
self.conn.close()
except Error:
messagebox.showerror("Error","Something goes wrong")
# label and input box
Label(self, text='Student Details',bg='gray', fg='white', font=('Courier new',
25, 'bold')).pack()
Label(self, text='Name:',bg='gray', font=('Courier new', 10,
'bold')).place(x=70, y=82)
Entry(self, textvariable=n, width=30).place(x=200, y=84)
Label(self, text='Phone Number:',bg='gray', font=('Courier new', 10,
'bold')).place(x=70, y=130)
Entry(self, textvariable=p, width=30).place(x=200, y=132)
Label(self, text='Address:',bg='gray', font=('Courier new', 10,
'bold')).place(x=70, y=180)
Entry(self, textvariable=a, width=30).place(x=200, y=182)
Button(self, text="Submit",width = 15,command=asi).place(x=230, y=220)
Add().mainloop()
#creating window
class issue(Tk):
def _init_(self):
super()._init_()
self.iconbitmap(r'libico.ico')
self.title('Library Admisintration')
self.maxsize(440, 300)
self.canvas = Canvas(width=1366, height=768, bg='gray')
self.canvas.pack()
c = StringVar()
d = StringVar()
#verifying input
def isb():
if (len(c.get())) == 0:
messagebox.showinfo('Error', 'Empty field!')
elif (len(d.get())) == 0:
messagebox.showinfo('Error', 'Empty field!')
else:
try:
self.conn = mysql.connector.connect(host='localhost',
database='library',
user='root',
password='')
self.mycursor = self.conn.cursor()
self.mycursor.execute("Select availability from book where
availability = 'YES' and book_id = %s", [c.get()])
self.pc = self.mycursor.fetchall()
try:
if self.pc:
print("success")
book = c.get()
stud = d.get()
now = datetime.now()
idate = now.strftime('%Y-%m-%d %H:%M:%S')
self.mycursor.execute("Insert into
issue_book(book_id,stud_id,issue_date,return_date) values (%s,%s,%s,%s)",
[book, stud, idate,''])
self.conn.commit()
self.mycursor.execute("Update book set availability = 'NO'
where book_id = %s", [book])
self.conn.commit()
messagebox.showinfo("Success", "Successfully Issue!")
ask = messagebox.askyesno("Confirm", "Do you want to add
another?")
if ask:
self.destroy()
os.system('%s %s' % (py, 'issueTable.py'))
else:
self.destroy()
else:
messagebox.showinfo("Oop's", "Book id "+c.get()+" is not
available")
except Error:
messagebox.showerror("Error", "Check The Details")
except Error:
messagebox.showerror("Error", "Something goes wrong")
class ret(Tk):
def _init_(self):
super()._init_()
self.iconbitmap(r'libico.ico')
self.title("Return")
self.maxsize(420,280)
self.canvas = Canvas(width=500, height=417, bg='gray')
self.canvas.pack()
self.cal = 0
a = StringVar()
def qui():
if len(a.get()) == '0':
messagebox.showerror("Error","Please Enter The Book Id")
else:
try:
self.conn = mysql.connector.connect(host='localhost',
database='library',
user='root',
password='')
self.mycursor = self.conn.cursor()
#creating window
class reg(Tk):
def _init_(self):
super()._init_()
self.iconbitmap(r'libico.ico')
self.maxsize(500, 417)
self.minsize(500, 417)
self.title('Add User')
self.canvas = Canvas(width=500, height=417, bg='gray')
self.canvas.pack()
#creating variables Please chech carefully
u = StringVar()
n = StringVar()
p = StringVar()
def insert():
try:
self.conn = mysql.connector.connect(host='localhost',
database='library',
user='root',
password='')
self.myCursor = self.conn.cursor()
self.myCursor.execute("Insert into admin(user,name,password) values
(%s,%s,%s)",[u.get(), n.get(), p.get()])
self.conn.commit()
messagebox.showinfo("Done", "User Inserted Successfully")
ask = messagebox.askyesno("Confirm", "Do you want to add another
user?")
if ask:
self.destroy()
os.system('%s %s' % (py, 'Reg.py'))
else:
self.destroy()
self.myCursor.close()
self.conn.close()
except Error:
messagebox.showinfo("Error", "Something Goes Wrong")
#label and input
Label(self, text='User Details', bg='gray', fg='black', font=('Courier new',
25, 'bold')).place(x=130, y=22)
Label(self, text='Username:', bg='gray', font=('Courier new', 10,
'bold')).place(x=70, y=82)
Entry(self, textvariable=u, width=30).place(x=200, y=84)
Label(self, text='Name:', bg='gray', font=('Courier new', 10,
'bold')).place(x=70, y=130)
Entry(self, textvariable=n, width=30).place(x=200, y=132)
Label(self, text='Password:', bg='gray', font=('Courier new', 10,
'bold')).place(x=70, y=180)
Entry(self, textvariable=p, width=30).place(x=200, y=182)
Button(self, text="Submit", width=15, command=insert).place(x=230,
y=220)
reg().mainloop()
MODULE FOR REMOVING OR DELETING THE USER –
from tkinter import *
from tkinter import messagebox
import mysql.connector
from mysql.connector import Error
#creating widow
class Rem(Tk):
def _init_(self):
super()._init_()
self.iconbitmap(r'libico.ico')
self.maxsize(400, 200)
self.minsize(400, 200)
self.title("Remove User")
self.canvas = Canvas(width=1366, height=768, bg='gray')
self.canvas.pack()
a = StringVar()
def ent():
if len(a.get()) ==0:
messagebox.showinfo("Error","Please Enter A Valid Id")
else:
d = messagebox.askyesno("Confirm", "Are you sure you want to
remove the user?")
if d:
try:
self.conn = mysql.connector.connect(host='localhost',
database='library',
user='root',
password='')
self.myCursor = self.conn.cursor()
self.myCursor.execute("Delete from admin where id =
%s",[a.get()])
self.conn.commit()
self.myCursor.close()
self.conn.close()
messagebox.showinfo("Confirm","User Removed Successfully")
a.set("")
except:
messagebox.showerror("Error","Something goes wrong")
Label(self, text = "Enter User Id: ",bg='gray',fg='black',font=('Courier
new', 15, 'bold')).place(x = 5,y = 40)
Entry(self,textvariable = a,width = 37).place(x = 160,y = 44)
Button(self, text='Remove', width=15, font=('arial', 10),command =
ent).place(x=200, y = 90)
Rem().mainloop()