SlideShare a Scribd company logo
1 of 21
DELHI PUBLIC SCHOOL KALYANPUR
SESSION – 2023-2024
COMPUTER SCIENCE
PROJECT FILE
SUBMITTED TO : SUBMITTED BY :
DISHA DIAS Akshat Singh Chaudhary
XII S7
Roll No. 1
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 Teacher
CONTENTS
S.No. TOPIC PAGE NO.
1. COVER PAGE (i)
2. ACKNOWLEDGEMENT (ii)
3. MAIN CODE FOR LIBRARY MANAGEMENT SYSTEM
4. DATABASE AND TABLE DESCRIPTION
5. EXECUTING THE CODE
6. ERRORS
7. BIBLIOGRAPHY
Main Code for Library Management System
#LIBRARY 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 **
=======================================
""")
#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()
flag=0
cur.execute("select * from login")
for i in cur: #if login doesn't have any value, loop will not execute!!
flag = 1
if flag==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 c==1: #Login
cont1=input("Enter Username : ")
cont2=input("Enter Password : ")
cur.execute("select * from login")
for i in cur:
t_user,t_pas=i
if cont1==t_user and cont2==t_pas:
print("Login Successful !!")
loop1='n'
while loop1=='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
----------------------------
""")
ch=int(input("Enter your choice : "))
if ch==1: #Adding 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+"','"+sub+"','"+str(quant)+"')")
mydb.commit()
print("Data inserted successfully !!")
loop2=input("Do you want to add more books? Press (y/n)
as per your choice : ").lower()
loop1=input("Do you want to logout? Press (y/n) as per your
choice : ").lower()
elif ch==2: #Removing Books
cur.execute("select id from available_books")
count=0
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
book : "))
cur.execute("select * from available_books")
flag=0
for i in cur:
t_id,t_name,t_sub,t_quant=i
if t_id==b_id:
flag=1
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 !!")
elif ch==3: #Issuing Books
b_id=int(input("Enter book id : "))
flag=0
cur.execute("select * from available_books where
id='"+str(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 !! ")
else:
if t_quant>0:
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_name+"','"+s_class+"','"+s
_doi+"','"+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_id=int(input("Enter id of the book to be returned : "))
sname=input("Enter name of the student who issued the book
: ")
flag=0
t_id=0
t_name=0
t_quant=0
c=0
c1=0
cur.execute("select distinct id from issued_books order by
id")
for i in cur:
if int(i[0])==b_id:
t_id=int(i[0])
flag+=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_name=str(i[0])
c=c+1
if c!=0:
cur.execute("select quantity from available_books
where id='"+str(t_id)+"'")
for j in cur:
t_quant=int(j[0])
c1+=1
if c1!=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")
a=cur.fetchall()
for i in a:
print(i)
mydb.commit()
elif ch==7:
break
else:
print("Invalid input !!")
else:
print("Wrong username/password !!")
elif c==2:
break
else:
print("Invalid input !!")
Database and Table Description
Database and the tables
Description of the table “available_books”
Description of the table “issued_books”
Description of the table “login”
Executing the Code:
Login
Adding New Books
Table “available_books” after adding books
Removing Books
Table “available_books” after removing book
Issuing Books
Table “available_books” after issuing books
Returning Book
Table “available_books” and Table “issued_books” after
returning book
Displaying Available Books
Displaying Issued Books
Exiting the program
Errors
Invalid Choice
Invalid Credentials
Wrong book id entered while Issuing or Removing book
Wrong input while returning book
BIBLIOGRAPHY:
 Computer Science with python – Sumita Arora
 www.mysql.com
 www.python.org

More Related Content

Similar to Python and MySQL Linking Class 12th Project File 23-24

12th-computer-science-practical-study-material-english-medium.pdf
12th-computer-science-practical-study-material-english-medium.pdf12th-computer-science-practical-study-material-english-medium.pdf
12th-computer-science-practical-study-material-english-medium.pdf
ansh552818
 
12th-computer-science-practical-study-material-english-medium.pdf
12th-computer-science-practical-study-material-english-medium.pdf12th-computer-science-practical-study-material-english-medium.pdf
12th-computer-science-practical-study-material-english-medium.pdf
rajputaman7777777
 
Python Cheat Sheet 2.0.pdf
Python Cheat Sheet 2.0.pdfPython Cheat Sheet 2.0.pdf
Python Cheat Sheet 2.0.pdf
Rahul Jain
 
COMPUTER SCIENCE PROJECT ON HISTORICAL PLACE.pptx
COMPUTER SCIENCE PROJECT ON HISTORICAL PLACE.pptxCOMPUTER SCIENCE PROJECT ON HISTORICAL PLACE.pptx
COMPUTER SCIENCE PROJECT ON HISTORICAL PLACE.pptx
mv9499596
 
Computer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdfComputer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdf
HIMANSUKUMAR12
 

Similar to Python and MySQL Linking Class 12th Project File 23-24 (16)

12th-computer-science-practical-study-material-english-medium.pdf
12th-computer-science-practical-study-material-english-medium.pdf12th-computer-science-practical-study-material-english-medium.pdf
12th-computer-science-practical-study-material-english-medium.pdf
 
12th-computer-science-practical-study-material-english-medium.pdf
12th-computer-science-practical-study-material-english-medium.pdf12th-computer-science-practical-study-material-english-medium.pdf
12th-computer-science-practical-study-material-english-medium.pdf
 
Postgresql İndex on Expression
Postgresql İndex on ExpressionPostgresql İndex on Expression
Postgresql İndex on Expression
 
Postgresql index-expression
Postgresql index-expressionPostgresql index-expression
Postgresql index-expression
 
Pymongo for the Clueless
Pymongo for the CluelessPymongo for the Clueless
Pymongo for the Clueless
 
Presentation on Pandas in _ detail .pptx
Presentation on Pandas in _ detail .pptxPresentation on Pandas in _ detail .pptx
Presentation on Pandas in _ detail .pptx
 
programming in C++ report
programming in C++ reportprogramming in C++ report
programming in C++ report
 
TicketBEKA? Ticket booking
TicketBEKA? Ticket bookingTicketBEKA? Ticket booking
TicketBEKA? Ticket booking
 
Python Cheat Sheet 2.0.pdf
Python Cheat Sheet 2.0.pdfPython Cheat Sheet 2.0.pdf
Python Cheat Sheet 2.0.pdf
 
Computer Project for class 12 CBSE on school management
Computer Project for class 12 CBSE on school managementComputer Project for class 12 CBSE on school management
Computer Project for class 12 CBSE on school management
 
project report in C++ programming and SQL
project report in C++ programming and SQLproject report in C++ programming and SQL
project report in C++ programming and SQL
 
Ip library management project
Ip library management projectIp library management project
Ip library management project
 
COMPUTER SCIENCE PROJECT ON HISTORICAL PLACE.pptx
COMPUTER SCIENCE PROJECT ON HISTORICAL PLACE.pptxCOMPUTER SCIENCE PROJECT ON HISTORICAL PLACE.pptx
COMPUTER SCIENCE PROJECT ON HISTORICAL PLACE.pptx
 
Computer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdfComputer_Practicals-file.doc.pdf
Computer_Practicals-file.doc.pdf
 
xii cs practicals
xii cs practicalsxii cs practicals
xii cs practicals
 
Beautiful python - PyLadies
Beautiful python - PyLadiesBeautiful python - PyLadies
Beautiful python - PyLadies
 

Recently uploaded

Poster_density_driven_with_fracture_MLMC.pdf
Poster_density_driven_with_fracture_MLMC.pdfPoster_density_driven_with_fracture_MLMC.pdf
Poster_density_driven_with_fracture_MLMC.pdf
Alexander Litvinenko
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
CaitlinCummins3
 

Recently uploaded (20)

Book Review of Run For Your Life Powerpoint
Book Review of Run For Your Life PowerpointBook Review of Run For Your Life Powerpoint
Book Review of Run For Your Life Powerpoint
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
Poster_density_driven_with_fracture_MLMC.pdf
Poster_density_driven_with_fracture_MLMC.pdfPoster_density_driven_with_fracture_MLMC.pdf
Poster_density_driven_with_fracture_MLMC.pdf
 
The Ball Poem- John Berryman_20240518_001617_0000.pptx
The Ball Poem- John Berryman_20240518_001617_0000.pptxThe Ball Poem- John Berryman_20240518_001617_0000.pptx
The Ball Poem- John Berryman_20240518_001617_0000.pptx
 
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING IIII BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 
How to Analyse Profit of a Sales Order in Odoo 17
How to Analyse Profit of a Sales Order in Odoo 17How to Analyse Profit of a Sales Order in Odoo 17
How to Analyse Profit of a Sales Order in Odoo 17
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
Championnat de France de Tennis de table/
Championnat de France de Tennis de table/Championnat de France de Tennis de table/
Championnat de France de Tennis de table/
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
Benefits and Challenges of OER by Shweta Babel.pptx
Benefits and Challenges of OER by Shweta Babel.pptxBenefits and Challenges of OER by Shweta Babel.pptx
Benefits and Challenges of OER by Shweta Babel.pptx
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
 

Python and MySQL Linking Class 12th Project File 23-24

  • 1. DELHI PUBLIC SCHOOL KALYANPUR SESSION – 2023-2024 COMPUTER SCIENCE PROJECT FILE SUBMITTED TO : SUBMITTED BY : DISHA DIAS Akshat Singh Chaudhary XII S7 Roll No. 1
  • 2. 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 Teacher
  • 3. CONTENTS S.No. TOPIC PAGE NO. 1. COVER PAGE (i) 2. ACKNOWLEDGEMENT (ii) 3. MAIN CODE FOR LIBRARY MANAGEMENT SYSTEM 4. DATABASE AND TABLE DESCRIPTION 5. EXECUTING THE CODE 6. ERRORS 7. BIBLIOGRAPHY
  • 4. Main Code for Library Management System
  • 5. #LIBRARY 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 ** ======================================= """) #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() flag=0 cur.execute("select * from login") for i in cur: #if login doesn't have any value, loop will not execute!! flag = 1 if flag==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 c==1: #Login cont1=input("Enter Username : ") cont2=input("Enter Password : ") cur.execute("select * from login") for i in cur: t_user,t_pas=i
  • 6. if cont1==t_user and cont2==t_pas: print("Login Successful !!") loop1='n' while loop1=='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 ---------------------------- """) ch=int(input("Enter your choice : ")) if ch==1: #Adding 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+"','"+sub+"','"+str(quant)+"')") mydb.commit() print("Data inserted successfully !!") loop2=input("Do you want to add more books? Press (y/n) as per your choice : ").lower() loop1=input("Do you want to logout? Press (y/n) as per your choice : ").lower() elif ch==2: #Removing Books cur.execute("select id from available_books") count=0 for i in cur: idd=i count=count+1 if count==0: print("There are no available books !!") else:
  • 7. b_id=int(input("Enter book id to remove the required book : ")) cur.execute("select * from available_books") flag=0 for i in cur: t_id,t_name,t_sub,t_quant=i if t_id==b_id: flag=1 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 !!") elif ch==3: #Issuing Books b_id=int(input("Enter book id : ")) flag=0 cur.execute("select * from available_books where id='"+str(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 !! ") else: if t_quant>0: 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_name+"','"+s_class+"','"+s _doi+"','"+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 !!")
  • 8. else: print("Books are issued already !! Please wait until they are returned or issue another book !!") elif ch==4: #Returning Books b_id=int(input("Enter id of the book to be returned : ")) sname=input("Enter name of the student who issued the book : ") flag=0 t_id=0 t_name=0 t_quant=0 c=0 c1=0 cur.execute("select distinct id from issued_books order by id") for i in cur: if int(i[0])==b_id: t_id=int(i[0]) flag+=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_name=str(i[0]) c=c+1 if c!=0: cur.execute("select quantity from available_books where id='"+str(t_id)+"'") for j in cur: t_quant=int(j[0]) c1+=1 if c1!=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:
  • 9. 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") a=cur.fetchall() for i in a: print(i) mydb.commit() elif ch==7: break else: print("Invalid input !!") else: print("Wrong username/password !!") elif c==2: break else: print("Invalid input !!")
  • 10. Database and Table Description
  • 11. Database and the tables Description of the table “available_books” Description of the table “issued_books”
  • 12. Description of the table “login”
  • 14. Table “available_books” after adding books Removing Books Table “available_books” after removing book
  • 15. Issuing Books Table “available_books” after issuing books Returning Book
  • 16. Table “available_books” and Table “issued_books” after returning book Displaying Available Books
  • 20. Wrong book id entered while Issuing or Removing book Wrong input while returning book
  • 21. BIBLIOGRAPHY:  Computer Science with python – Sumita Arora  www.mysql.com  www.python.org