0% found this document useful (0 votes)
14 views21 pages

Library Management Class 12

The document is a project report by Prachi from UCSKM Public School on Library Management using Python Programming and SQL queries for the academic session 2022-2023. It includes a certificate of completion, acknowledgments, an index, detailed descriptions of functions and modules, source code, and output related to the library management system. The project involves creating and managing a database with tables for books, issues, and returns, along with various functionalities for adding, issuing, returning, and deleting books.

Uploaded by

Panav Bora
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views21 pages

Library Management Class 12

The document is a project report by Prachi from UCSKM Public School on Library Management using Python Programming and SQL queries for the academic session 2022-2023. It includes a certificate of completion, acknowledgments, an index, detailed descriptions of functions and modules, source code, and output related to the library management system. The project involves creating and managing a database with tables for books, issues, and returns, along with various functionalities for adding, issuing, returning, and deleting books.

Uploaded by

Panav Bora
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

UCSKM PUBLIC SCHOOL

BHIWADI

Session - 2022-23
Computer Science (083)
Library Management

Submitted By: Submitted To:


Prachi Mrs. Hema Sharma

Class- XII Commerce “B”

Board Roll Number:-


CERTIFICATE
This is hereby to certify that the investigatory work has been carried out to investigate
about the subject, matter and the related data collection and investigation has been
completed solely, sincerely and satisfactorily done by Prachi a student of class XII Com”B”
for the academic session 2022-2023 regarding the project entitled Python Programming and
SQL queries.

Signature Signature Signature


Internal examiner Principal External examiner

…………………………………. ………………………… ……………………………


Acknowledgement
I would like to express a deep sense of thanks & gratitude to my
project guide Mrs. Hema Sharma for guiding me immensely through
the course of the project. She always evinced keen interest in work.
Her constructive advice and constant motivation have been
responsible for the successful completion of this project.

My sincere thanks go to Dr. Prabhat Kaushik, our principal, for his co-
ordination in extending every possible support for the completion of
this project.

Finally, I would like to thank all those who had helped directly or
indirectly towards the completion of this project.

Prachi

Class- XII Com “B”


INDEX
FUNCTIONS AND MODULES ....................................... 5
Modules: ..................................................................... 5
Functions:.................................................................... 5
DETAILED DESCRIPTION ............................................ 8
SOURCE ...................................................................... 10
CODE........................................................................... 10
PYTHON.................................................................... 11
OUTPUT .................................................................... 17
SQL COMMAND ........................................................ 20
LIBRARY MANAGEMENT

FUNCTIONS AND MODULES


Modules:

import mysql.connector:
By importing this package, we are able to establish the connection
between SQL and Python.

Functions:

 connect():

This function establishes connection between Python and MySQL

 cursor():

It is a special control structure that facilitates the row-by- row


processing of records in the result set.
The Syntax is:
<cursor object>=<connection object>.cursor()

 execute():

This function is used to execute the sql query and retrieve records
using python.
The syntax is:

<cursor object>.execute(<sql query string>)

 def():

A function is a block of code which only runs when it is called.

 fetchall():

This function will return all the rows from the result set in the form
of a tuple containing the records.
 fetchone():

This Function will return one row from the result set in the form of a
tuple containing the records.

 commit():

This function provides changes in the database physically.


DETAILED DESCRIPTION
Our Project has 3 MySQL tables. These are: -

1.) Books

2.) Issue

3.) Return

1) The table Books contain the following columns:

a) bname

b) author

c) bcode
d) total

e) subject

2.) The table Issue contain the following columns:


a.) name
b.) regno

c.) bcode

d.) issue_date
3.) The table Return contain the following columns:

a.) name

b.) regno
c.) bcode

d.) return_date
SOURCE
CODE
PYTHON

import mysql.connector as a
print("""

*******************************************************
**************************************************
WELCOME TO
LIBRARY MANAGEMENT

*******************************************************
**************************************************
""")
print("""
DESIGNED AND MAINTAINED BY
PRACHI CLASS:XII COMMERCE"B
""")
con =
a.connect(host="localhost",user="root",password="hrithi
k_@123")
c =con.cursor()
c.execute("Create database if not exists library_app")
c.execute("use library_app")
c.execute("create table if not exists books(bname
varchar(50),author varchar(50),bcode varchar(50),total
int(50),subject varchar(50))")
c.execute("create table if not exists issue(name
varchar(50),regno varchar(50),bcode int(50),issue_date
varchar(50))")
c.execute("create table if not exists ret(name
varchar(50),regno varchar(50),bcode int(50),return_date
varchar(50))")
con.commit()
def addbook():
bn =input("Enter Book Name: ")
ba =input("Enter Author's 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\nBooked Successful
Added..........\n\n\n\n")
wait = input('\n\n\nPress enter to
continue.....\n\n\n\n\n\n')
main()

def issueb():
n=input("Enter Student Name: ")
r=int(input("Enter Reg No.: "))
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\nBook issued successfully to: ",n)
wait = input('\n\n\nPress enter to
continue.....\n\n\n\n\n\n')
bookup(co,-1)
main()
def retb():
n=input("Enter Student Name:")
r=int(input("Enter Reg No.: "))
co=int(input("Enter Book Code: "))
d =input("Enter Date: ")
a="insert into ret 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\nPress enter to
continue.....\n\n\n\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.fetchone()
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\nPress enter to
continue.....\n\n\n\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\nPress enter to
continue.....\n\n\n\n\n\n\n\n\n\n\n\n")
main()

def displaybook():
a="select * from books;"
c=con.cursor()
c.execute(a)
myresult=c.fetchall()
for i in myresult:
print("Book name: ",i[0])
print("Author: ",[1])
print("Book code: ",[2])
print("Total:",i[3])
print("Subject:",i[4])
print("\n\n")

wait= input("\n\n\nPress enter to


continue.....\n\n\n\n\n\n\n\n\n\n\n\n")
main()

def report_issued_books():
a="select from issue;"
c=con.cursor()
c.execute(a)
myresult=c.fetchall()
for i in myresult:
print(myresult)

wait = input("\n\n\nPress enter to


continue.....\n\n\n\n\n\n\n\n")
main()

def report_return_22_books():
a="select * from ret;"
c=con.cursor()
c.execute(a)
result=c.fetchall()
for i in myresult:
print(myresult)

wait = input("\n\n\nPress enter to


continue.....\n\n\n\n\n\n\n\n\n\n\n\n")
main()

def main():
print("""
LIBRARY MANAGEMENT APPLICATION
1. ADD BOOK
2. ISSUE OF BOOK
3. RETURN OF BOOK
4. DELETE BOOK
5. DISPLAY BOOKS
6. REPORT MENU
7. EXIT PROGRAM
""")

choice=input("Enter Task No:......")


print("\n\n\n\n\n\n\n")

if(choice=='1'):
addbook()
elif(choice =='2'):
issueb()
elif(choice =='3'):
retb()
elif(choice=='4'):
dbook()
elif(choice=='5'):
displaybook()
elif(choice=='6'):
print(""" REPORT MENU

1. ISSUED BOOKS
2. RETURNED BOOKS
3. GO BACK TO MAIN MENU
\n\n\n
""")
choice=input("Enter Task No:......")
print("\n\n\n\n\n\n\n")
if choice=='1':
report_issued_books()
elif choice=='2':
report_ret_books()
elif choice=='3':
main()

else:
print("Please try
again........\n\n\n\n\n\n\n\n\n")
main()
elif(choice=="7"):
print('\n\n\n\n\n\n\n\n\n\n\n\nThank you and
have a great day
ahead.............\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n')
else:
print("Please try
again........\n\n\n\n\n\n\n\n\n\n\n\n")
main()

main()
OUTPUT
1. Add books
2. Issue a book
3. Return of books
SQL COMMAND
BIBLIOGRAPHY
 CS kips Class 12 Textbook
 Class 12 NCERT Textbook
 www.google.com

You might also like