This project is made using two parts.
First : coding for making tables in mysql server.
Second : coding for using project interface.
Software Requirements
Mysql server : mysql server must be installed in computer. It will be used for accessing data of project. Tables will be made in server in which data will be stored.
Python idle : python idle must be installed in computer. It will be used for executing python scripts.
Mysql.connector : it will connect python idle with mysql server. To install it open cmd and write pip install mysql.connector
MySQL
In user and passwd, put your mysql server username and password.
import mysql.connector as a
con = a.connect(host="localhost",
user="root",
passwd="12345")
c = con.cursor()
sql1 = "create database l1"
c.execute(sql1)
sql2 = "use l1"
c.execute(sql2)
sql3 = "create table books (bname varchar(50),bcode varchar(10), total int, subject varchar(50))"
c.execute(sql3)
sql4 = "create table issue (sname varchar(50),regno varchar(10), bcode varchar(10), idate varchar(10))"
c.execute(sql4)
sql5 = "create table submit (sname varchar(50), regno varchar(10), bcode varchar(10), sdate varchar(10))"
c.execute(sql5)
con.commit()Python
After executing the python script the password for opening the interface is pypr.
import mysql.connector as a
con = a.connect(host="localhost",user="root", passwd = "12345")
c = con.cursor()
c.execute("show databases")
dl = c.fetchall()
dl2 = []
for i in dl:
dl2.append(i[0])
if 'l1' in dl2:
sql = "use l1"
c.execute(sql)
else:
sql1 = "create database l1"
c.execute(sql1)
sql2 = "use l1"
c.execute(sql2)
sql3 = "create table books (bname varchar(50),bcode varchar(10), total int, subject varchar(50))"
c.execute(sql3)
sql4 = "create table issue (sname varchar(50),regno varchar(10), bcode varchar(10), idate varchar(10))"
c.execute(sql4)
sql5 = "create table submit (sname varchar(50), regno varchar(10), bcode varchar(10), sdate varchar(10))"
c.execute(sql5)
con.commit()
def pswd():
ps = input("Enter Password : ")
if ps == "pypr":
main()
else:
print("Wrong Password")
pswd()
def main():
print("""
LIBRARY MANAGER
1. ADD 2. ISSUE 3. SUBMIT 4. REMOVE 5. DISPLAY
""")
choice = input("Enter Task No : ")
print(">--------------------------------------------------------------------------------------------<")
if (choice == '1'):
addbook()
elif (choice=='2'):
issueb()
elif (choice=='3'):
submitb()
elif (choice=='4'):
rbook()
elif (choice=='5'):
print("1. All 2. Issued")
ch = input("Enter Task No. ")
print(">--------------------------------------------------------------------------------------------<")
if ch == '1':
abooks()
else:
ibooks()
else :
print(" Wrong choice..........")
main()
def addbook():
bn = input("Enter BOOK Name : ")
c = input("Enter BOOK Code : ")
t = input("Total Books : ")
s = input("Enter Subject : ")
data = (bn,c,t,s)
sql = 'insert into books values(%s,%s,%s,%s)'
c = con.cursor()
c.execute(sql,data)
con.commit()
print(">----------------------------------------------------------------------------------------<")
print("Data Entered Successfully")
main()
def issueb():
n = input("Enter Name : ")
r = input("Enter Reg No : ")
co = input("Enter Book Code : ")
d = input("Enter Date : ")
a = "insert into issue values(%s,%s,%s,%s)"
data = (n,r,co,d)
c = con.cursor()
c.execute(a,data)
con.commit()
print(">--------------------------------------------------------------------------------------------<")
print("Book issued to : ",n)
bookup(co,-1)
def submitb():
n = input("Enter Name : ")
r = input("Enter Reg No : ")
co = input("Enter Book Code : ")
d = input("Enter Date : ")
a = "insert into submit values(%s,%s,%s,%s)"
data = (n,r,co,d)
c = con.cursor()
c.execute(a,data)
con.commit()
print(">--------------------------------------------------------------------------------------------<")
print("Book Submitted from : ",n)
bookup(co,1)
def bookup(co,u):
a = "select TOTAL from books where BCODE = %s"
data = (co,)
c = con.cursor()
c.execute(a,data) # (10,)
myresult = c.fetchone()
t = myresult[0] + u
sql = "update books set TOTAL = %s where BCODE = %s"
d = (t,co)
c.execute(sql,d)
con.commit()
main()
def rbook():
ac = input("Enter Book Code : ")
a = "delete from books where BCODE = %s"
data = (ac,)
c = con.cursor()
c.execute(a,data)
con.commit()
main()
def abooks():
a = "select * from books"
c = con.cursor()
c.execute(a)
myresult = c.fetchall() # [(1,2,3,4),(1,2,3,4)]
for i in myresult:
print("Book Name : ",i[0])
print("Book Code : ",i[1])
print("Total : ",i[2])
print("Subject : ",i[3])
print(">--------------------------------<")
main()
def ibooks():
a = "select * from issue"
c = con.cursor()
c.execute(a)
myresult = c.fetchall() # [(1,2,3,4),(1,2,3,4)]
for i in myresult:
print("Student Name : ",i[0])
print("Reg No : ",i[1])
print("Book Code : ",i[2])
print("Issue Date : ",i[3])
print(">--------------------------------<")
main()
pswd()
Educational Use Notice
This project is provided strictly for educational and learning purposes. Students are encouraged to study the code, understand the concepts, and use it as a reference for building their own original projects. Users are expected to modify, improve, and create their own implementations based on their understanding. By accessing this project, you agree to use it ethically and in accordance with your institution’s academic integrity policies.