Cs Main

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 17

OUTPUTS :-

CREATING TABLE’S:-
TABLE BOOKS

TABLE ISSUE

TABLE RETURN
ADDING BOOKS:
ISSUING OF BOOK TO STUDENT:
RETURN OF BOOKS:
DELETING BOOK FROM ‘BOOKS’ TABLE:
DISPLAY OF BOOKS:
SOURCE CODE:

import mysql.connector as a
con=a.connect(host='localhost',user='root',passwd='t
ushar',database='library_app')

print("""

LIBRARY MANAGEMENT SYSTEM

1. ADD BOOK
2. ISSUE OF BOOK
3. RETURN OF BOOK
4. DELETE BOOK
5. DISPLAY BOOKS
6. EXIT PROGRAM
""")
def addbook():
bn=input("Enter Book Name:")
ba=input("Enter Authors Name:")
c=int(input("Enter Book Code:"))
t=int(input("Total Books:"))
s=input("Enter Subject:")
data=(bn,ba,c,t,s)
sql='insert into books values(%s,%s,%s,%s,%s);'
c=con.cursor()
c.execute(sql,data)
con.commit()
print("""\n\n\n\n Book Added Successfully """)
wait=input('\n\n\n Press enter to continue \n\n\n')
main()
def issueb():
n=input("Enter Student Name:")
r=int(input("Enter Registration Number:"))
co=int(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("\n\n\n Book issued succesfully to:",n)
wait=input('\n\n\n Press enter to continue \n\n\n')
bookup(co,-1)
main()
def returnb():
n=input("Enter Student Name:")
r=int(input("Enter Registration Number:"))
co=int(input("Enter Book Code:"))
d=input("Enter Date:")
a="insert into book_return values(%s,%s,%s,%s);"
data=(n,r,co,d)
c=con.cursor()
c.execute(a,data)
con.commit()
print("Book returned by:",n)
wait=input('\n\n\n Press enter to continue \n\n\n')
bookup(co,-1)
main()
def bookup(co,u):
a="select total from books where bcode=%s;"
data=(co,)
c=con.cursor()
c.execute(a,data)
myresult=c.fetcone()
t=myresult[0]+u
sql="update books set total=%s where bcode=%s;"
d=(t,co)
c.execute(sql,d)
con.commit()
wait=input('\n\n\n Press enter to continue \n\n\n')
main()
def dbook():
ac=int(input("Enter Book Code:"))
a="delete from books where bcode=%s;"
data=(ac,)
c=con.cursor()
c.execute(a,data)
con.commit()
print("Book Deleted Successfully")
wait=input("\n\n\n Press enter to continue\n\n\n")
main()
def dispbook():
a="select * from books;"
c=con.cursor()
c.execute(a)
myresult=c.fetchall()
for i in myresult:
print("Book Name:",i[0])
print("Author:",i[1])
print("Book Code:",i[2])
print("Total:",i[3])
print("Subject:",i[4])
print('\n\n')
wait=input("\n\n\n Press enter to continue \n\n\
n")
main()
def main():
print("""

LIBRARY MANAGEMENT SYSTEM

1. ADD BOOK

2. ISSUE OF BOOK

3. RETURN OF BOOK

4. DELETE BOOK

5. DISPLAY BOOKS

6. EXIT PROGRAM
""")
choice=input("Enter Task No:-")
if(choice=='1'):
addbook()
elif(choice=='2'):
issueb()
elif(choice=='3'):
returnb()
elif(choice=='4'):
dbook()
elif(choice=='5'):
dispbook()
elif(choice=='6'):
print("""\n\n\n\n\n\n\n\n\n\n\n THANK YOU
HAVE A GREAT DAY AHEAD \n\n\n\n\n\n\n\n""")
else:
print("PLEASE TRY AGAIN \n\n\n\n\n")
main()
main()
BIBLIOGRAPHY:
C.S BOOK CLASS XII (SUMITA ARORA)
https://www.geeksforgeeks.org/
https://www.w3schools.com/

You might also like