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
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 !!")