0 ratings0% found this document useful (0 votes) 35 views20 pagesClass 12 CS Project File
Class 12 Computer science Project file
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
ACKNOWLEDGEMENT
I would like to convey my heartfelt thanks to Ms. Disha Dias my
faculty of Computer Science who gave her valuable suggestions
and guidance for the completion of my project. She helped me to
comprehend important details of the project. My project has been
successful only because of her able guidance and support.
‘Signature of the Principal ‘Signature of the Subject TeacherCONTENTS
TOPIC PAGE NO,
COVER PAGE w
ACKNOWLEDGEMENT Gi)
MAIN CODE FOR LIBRARY MANAGEMENT SYSTEM
DATABASE AND TABLE DESCRIPTION
EXECUTING THE CODE
ERRORS
BIBLIOGRAPHYMain Code for Library Management SystemLIBRARY MANAGEMENT SYSTEM:
import mysql.connector as msc
mydb=msc. connect (host=" localhost’ ,user="root' ,passwd="python' )
cur=mydb. cursor()
print("*"
* Welcome to Library Management System **
“any
#Creating Database:
cur.execute("create database if not exists library_management_system")
cur.execute("use library_management_system")
cur.execute("create table if not exists available_books(id int primary key not
null,name varchar(25) not null,subject varchar(25) not null,quantity int not
null)")
cur.execute("create table if not exists issued_books(id int not null,book_name
varchar(25) not null,book_subject varchar(25) not null,stu_name varchar(200)
primary key not null,stu_class varchar(25) not null,date_of_issue date not
null,date_of_return date not null)")
cur.execute("create table if not exists login(user varchar(25) not
null, password varchar(25) primary key not null)")
mydb. commit ()
flags
cur.execute("select * from login")
for i in cur: #if login doesn't have any value, loop will not execute!!
flag = 1
if flage=0:
cur.execute("insert into login values(‘Admin@123" ,'1234')")
mydb. commit ()
#Loop-->Main Working
while True:
print("""
1. Login
2.Exit
=
c=int(input("Enter your choice : "))
if cee1: #login
conti=input("Enter Username : ")
cont2=input("Enter Password : “)
cur.execute("select * from login")
for i in cur:
t_user, t_pas=iif cont1==t_user and cont2==t_pas:
print("Login Successful 11")
loopi='n"
while loopl=='n':
print("""
1. Add new books
2. Remove any book
3. Issue book to student
4. Return book
5. View available books
6. View issued books
7. Logout
“my
ch=int(input("Enter your choice : "))
if che=1: wadding Books
loop2="y
while loop2=="'y':
print("Please enter the required data correctly !!")
b_id=int(input("Enter book id : "))
b_name=input("Enter book name : ")
Sub=input("Enter subject : ")
quant=int(input("“Enter quantity : “))
cur.execute("insert into available_books
values('"+str(b_id)+"",‘"+b_name+"', ‘"+sube"", ‘"+ste(quant)+"")")
mydb. commit ()
print("Data inserted successfully !!")
oop2=input ("Do you want to add more books? Press (y/n)
as per your choice : “).lower()
loopi=input("Do you want to logout? Press (y/n) as per your
choice : “).lower()
elif che=2: #Removing Books
cur.execute("select id from available_books")
count=@
for i in cur:
idd=i
count=count+1
if count==0:
print("There are no available books !!")
else:b_id=int(input("Enter book id to remove the required
cur.execute("select * from available_books")
flag=@
for i in cur:
t_id, t_name, t_sub,t_quant=i
if t_ide=b_id:
flage1
if flag==1:
cur.execute(“delete from available_books where
id='"+str(b_id)+""")
mydb.commit()
print("Data deleted successfully !!")
else:
print("Please enter correct id 11")
elif ch==3: #Issuing Books
b_Ad-int(input("Enter book id : "))
Flag=0
cur.execute("select * from available_books where
id='"+ste(b_id)+""")
for i in cur:
t_id, t_name, t_sub, t_quant=i
flag=1
if flag!=1:
print("Please enter the correct id as per the available
books I! ")
else:
if t_quant>e:
S_name=input("Enter student name : ")
s_class=input("Enter student class : “)
s_doi=input(“Enter date of issue : “)
s_dor=input(“Enter date of return : ")
cur.execute("insert into issued_books
values(‘"+str(b_id)+"",'"+t_name+"','"+t_sub+"', "+s _names"?, '"+s_classe"', '"+s
_doit"*, *"+s_dor+"*)")
quan=t_quant-1.
cur.execute("update available_books set
quantity='"+str(quan)+"" where id='"+str(b_id)+"'")
mydb.commit()
print("Book issued successfully !!")else:
print("Books are issued already !! Please wait
until they are returned or issue another book !!")
elif ch==4: #Returning Books
b_idsint(input("Enter id of the book to be returned : "))
-) sname=input("Enter name of the student who issued the book
flag-0
tidee
t_name=0
t_quant=@
c=8
1-0
3 cur.execute("select distinct id from issued_books order by
o
for i in cur:
if int(i[@])==b_id:
t_idsint(i[e])
flagt=1
if flag==0:
print("No such book is issued !!")
else:
cur.execute("select stu_name from available_books
A,issued_books I where A.id='"+str(t_id)+"' and A.id=I.id and
I. stu_name='"+sname+"*")
for i in cur:
t_namesstr(i[@])
cect]
if cl=0:
cur.execute("select quantity from available_books
where id='"+str(t_id)+"'")
for j in cur:
t_quant=int(j[@])
clt=1
if c1l=0:
quant=t_quant+1
cur.execute("update available_books set
quantity=""+str(quant)+"" where id='"+str(t_id)+"'")
cur.execute(“delete from issued_books where
id='"+str(t_id)+"' and stu_name='"+t_name+"'")
mydb. commit ()
print("Book returned successfully !!")
else:print("No such student has issued this book !!")
elif ch==5: #Display Books
print("ID , NAME , SUBJECT , QUANTITY")
cur.execute("select * from available_books")
a=cur.fetchall()
for i in a:
print(i)
mydb. commit ()
elif ch==6: #Display Issued Books
print("ID , NAME , SUBJECT , S_NAME , S CLASS")
cur.execute(select * from issued_books")
azcur.fetchall()
for i in a:
print (i)
mydb..commit()
elif ch==7:
break
else:
print("Invalid input !!")
else:
print("Wrong username/password !!")
elif cx=2:
break
else:
print("Invalid input !!")Database and Table DescriptionDescription of the table “issued_books”Description of the table “login”Executing the Code:
Adding New BooksTable “available_books” after removing bookIssuing Books
Table “available_books” after issuing books
Returning BookTable “available_books” and Table “issued_books” after
returning book
Displaying Available BooksAdd new books
‘any book
Toeue book to student
Return book
View available books
View Issued books
Logout
Enter your choice + €
1D , MAME, SUBJECT , MAME, 9 CLASS
3," toavat!, ‘athematics', ‘Anahuman’
Displaying Issued Books
+ 112", datetine.date (2023, 12, 20), datetime.date(2023, 12, 271)
1. Add new books
2. Remove any book
3. Issue book to student
4. Return book
5. View available books
6. View issued books
7. Logout
Enter your choice : 7
1.Login
2.Exit
Enter your choice : 2
>>>
Exiting the programErrorsAdd new books
Remove any book
Issue book to student
Return book
View available books
View issued books
Enter your choice
Invalid input !!
Invalid Choice
** Welcome to Library Management System **
1.Login
2.Exit
Enter your choice : 1
Enter Username : Navdeep
Enter Password : 12
Wrong username/password !!
1.Login
2.Exit
Enter your choice :
Invalid CredentialsAdd new books
Remove any book
Issue book to student
Return book
View available books
View issued books
Enter your choice : 3
Enter book id : 34
[Please enter the correct id as per the available books !!
1. Add new books
2. Remove any book
3. Issue book to student
4. Return book
| 5. View available books
6. View issued books
| 7. Logout
Enter your choice : 2
Enter book id to remove the required book : 76
|Please enter correct id !!
Wrong book id entered while Issuing or Removing book
1. Add new books
2. Remove any book
3. Issue book to student
4. Return book
5. View available books
6. View issued books
7. Logout
lenter your choice : 4
|Enter id of the book to be returned : 34
|Enter name of the student who issued the book : Akshat
No such book is issued !!
Wrong input while returning bookBIBLIOGRAPHY:
© Computer Science with python — Sumita Arora
©¢ www.mysql.com
© www.python.org