SlideShare a Scribd company logo
5
Most read
6
Most read
8
Most read
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

ODT
Library Management Project (computer science) class 12
PDF
Computer science project.pdf
DOCX
Ip library management project
DOCX
computer science with python project for class 12 cbse
PDF
BOOK SHOP SYSTEM Project in Python
PDF
Computer science Project for class 11th and 12th(library management system)
PDF
Computer project final for class 12 Students
PDF
Computer Science Investigatory Project Class 12
Library Management Project (computer science) class 12
Computer science project.pdf
Ip library management project
computer science with python project for class 12 cbse
BOOK SHOP SYSTEM Project in Python
Computer science Project for class 11th and 12th(library management system)
Computer project final for class 12 Students
Computer Science Investigatory Project Class 12

What's hot (20)

PDF
Informatics Practices/ Information Practices Project (IP Project Class 12)
DOCX
class 12th computer science project Employee Management System In Python
PDF
Library Management Python, MySQL
PDF
Employee Management (CS Project for 12th CBSE)
PDF
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
PDF
PHYSICS INVESTIGATORY PROJECT 2017-18
DOCX
Acknowledgement
DOCX
Computer Science Practical File class XII
PDF
Computer Project for class 12 CBSE on school management
DOCX
CBSE Class 12 Computer practical Python Programs and MYSQL
PDF
chemistry investigatory project on to determine the rate evaporation of diffe...
DOCX
Project front page, index, certificate, and acknowledgement
DOCX
Foaming Capacity of Soap
PDF
COMPUTER SCIENCE PROJECT OF RAILWAY RESERVATION SYSTEM PYTHON PROGRAMMING.pdf
PDF
Indigo
PDF
Class 12th Physics Project File (Capacitors) 23-24
PDF
To Study the earth's magnetic field using a tangent galvanometer Tangent galv...
DOCX
Physics Investigatory Project Class 12
PDF
12th Physics Investigatory project (LDR)
PPTX
Cyber Crime
Informatics Practices/ Information Practices Project (IP Project Class 12)
class 12th computer science project Employee Management System In Python
Library Management Python, MySQL
Employee Management (CS Project for 12th CBSE)
BANK MANAGEMENT INVESTIGATORY PROJECT CLASS 12TH
PHYSICS INVESTIGATORY PROJECT 2017-18
Acknowledgement
Computer Science Practical File class XII
Computer Project for class 12 CBSE on school management
CBSE Class 12 Computer practical Python Programs and MYSQL
chemistry investigatory project on to determine the rate evaporation of diffe...
Project front page, index, certificate, and acknowledgement
Foaming Capacity of Soap
COMPUTER SCIENCE PROJECT OF RAILWAY RESERVATION SYSTEM PYTHON PROGRAMMING.pdf
Indigo
Class 12th Physics Project File (Capacitors) 23-24
To Study the earth's magnetic field using a tangent galvanometer Tangent galv...
Physics Investigatory Project Class 12
12th Physics Investigatory project (LDR)
Cyber Crime
Ad

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

DOCX
Lokesh 's Ip project Pokemon information
PDF
anjliji.pdf
PDF
dv-210220053508_removed.pdf
PDF
Thakur ip project class 12 on topic of library department
DOCX
Project Term2 Computer barun.docx
PDF
school-management-by-shivkamal-singh.pdf
PDF
Digital-Library with pdf for class 12 c.s
PPTX
Coding about python and MySQL connectivity
DOCX
c++ library management
PPTX
yash shakya.pptx
PPTX
Library management system version 2 using to CodeIgniter 4 Framework PPT
PDF
PPTX
Library_Management_Project_Presentation.pptx
PPTX
C++ student management system
PPTX
LIBRARY MANAGEMENT SYSTEM ppt.pptx
PDF
aprojectreportonlibraymgtsystem2-141114055422-conversion-gate02 (1).pdf
DOCX
A project report on libray mgt system
PDF
PPTX
MySql Interface database in sql python my.pptx
DOC
Library Management System in c++
Lokesh 's Ip project Pokemon information
anjliji.pdf
dv-210220053508_removed.pdf
Thakur ip project class 12 on topic of library department
Project Term2 Computer barun.docx
school-management-by-shivkamal-singh.pdf
Digital-Library with pdf for class 12 c.s
Coding about python and MySQL connectivity
c++ library management
yash shakya.pptx
Library management system version 2 using to CodeIgniter 4 Framework PPT
Library_Management_Project_Presentation.pptx
C++ student management system
LIBRARY MANAGEMENT SYSTEM ppt.pptx
aprojectreportonlibraymgtsystem2-141114055422-conversion-gate02 (1).pdf
A project report on libray mgt system
MySql Interface database in sql python my.pptx
Library Management System in c++
Ad

Recently uploaded (20)

PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
Institutional Correction lecture only . . .
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Cell Types and Its function , kingdom of life
PDF
RMMM.pdf make it easy to upload and study
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Business Ethics Teaching Materials for college
PDF
Complications of Minimal Access Surgery at WLH
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Cell Structure & Organelles in detailed.
PPTX
master seminar digital applications in india
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
TR - Agricultural Crops Production NC III.pdf
Institutional Correction lecture only . . .
Final Presentation General Medicine 03-08-2024.pptx
102 student loan defaulters named and shamed – Is someone you know on the list?
Cell Types and Its function , kingdom of life
RMMM.pdf make it easy to upload and study
Week 4 Term 3 Study Techniques revisited.pptx
O5-L3 Freight Transport Ops (International) V1.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Business Ethics Teaching Materials for college
Complications of Minimal Access Surgery at WLH
Anesthesia in Laparoscopic Surgery in India
Cell Structure & Organelles in detailed.
master seminar digital applications in india
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Renaissance Architecture: A Journey from Faith to Humanism

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