Project CS
Project CS
PROJECT ON
LIBRARY MANAGEMENT SYSTEM
As per CBSE AISSCE guidelines for Board Examination
Page 1 of 23
PM SHRI K.V. K.N.N. G.Z.B.- I
CERTIFICATE
This is to certify that Master PRATYUSH and Master HIMAL TYAGI
Page 2 of 23
TABLE OF CONTENTS
01 ACKNOWLEDGEMENT 04
02 INTRODUCTION 05
07 OUTPUT 17-21
08 SOFTWARE REQUIREMENT 22
09 CREDITS 23
Page 3 of 23
ACKNOWLEDGEMENT
Apart from the efforts, the success of any project depends largely on the
encouragement and guidelines of many others. We take this opportunity to express
our gratitude to the people who have been instrumental in the successful completion
of this project.
We express deep sense of gratitude to almighty God for giving us strength for
the successful completion of the project.
We express our sincerity and thanks to the academician The Principal, Vice
principal for constant encouragement and the guidance provided during this project
The guidance and support received from all the members who contributed and
who are contributing to this project, was vital for the success of the project. We are
grateful for their constant support and help.
Page 4 of 23
PROJECT ON CREATING LIBRARY MANAGEMENT SYSTEM
INTRODUCTION
This program helps the user to manage a library. This program helps the librarian or
admin to add or remove a book from their system and view all the books that have
been borrowed, when they were borrowed and when they are to be returned.
Through this program members can search and borrow the book they desire and
return the books they have borrowed. Also new users can register themselves as
members using this program.
This program also asks for the login credentials of the members or admins before
checking them with the database and then grants access to the menus.
This program is one example of how librarians can store and fetch data within second
and efficiently.
The objective of this project is to let the students apply the programming
knowledge and set a small example how librarians can organise the library and also
exposes the students to how programming skills helps in developing a good software.
different my SQL table structure .One is for storing the login credentials of the
members of the library. Second one is for storing the login credentials of the
admins/librarian. Third one is for storing the information of the books in the library. Last
is for storing the information regarding all the borrowed books and it is linked with the
Page 5 of 23
FEATURES OF LIBRARY MANAGEMENT
Page 6 of 23
TABLE STRUCSTURE FOR LIBRARY
MANAGEMENT
• ADMINS
FIELD TYPE NULL KEY DEFAULT EXTRA
id int NO PRI NULL auto_increment
• MEMBERS
FIELD TYPE NULL KEY DEFAULT EXTRA
id int NO PRI NULL auto_increment
• BOOKS
FIELD TYPE NULL KEY DEFAULT EXTRA
id int NO PRI NULL auto_increment
Page 7 of 23
• BORROWINGS
FIELD TYPE NULL KEY DEFAULT EXTRA
id int NO PRI NULL auto_increment
Page 8 of 23
SOURCE CODE
import mysql.connector
def create_connection():
connection = mysql.connector.connect(
host="localhost",
user="root",
password="1234567890",
database="library"
)
return connection
def create_tables(connection):
cursor = connection.cursor()
cursor.execute("""
CREATE TABLE IF NOT EXISTS books (
id INT AUTO_INCREMENT,
title VARCHAR(255) NOT NULL,
author VARCHAR(255) NOT NULL,
publication_date DATE NOT NULL,
PRIMARY KEY (id)
)
""")
cursor.execute("""
CREATE TABLE IF NOT EXISTS members (
id INT AUTO_INCREMENT,
name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
phone_number VARCHAR(20) NOT NULL,
Page 9 of 23
password VARCHAR(255) NOT NULL,
PRIMARY KEY (id)
)
""")
cursor.execute("""
CREATE TABLE IF NOT EXISTS admins (
id INT AUTO_INCREMENT,
username VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
PRIMARY KEY (id)
)
""")
cursor.execute("""
CREATE TABLE IF NOT EXISTS borrowings (
id INT AUTO_INCREMENT,
book_id INT NOT NULL,
member_id INT NOT NULL,
borrow_date DATE NOT NULL,
return_date DATE,
PRIMARY KEY (id),
FOREIGN KEY (book_id) REFERENCES books(id),
FOREIGN KEY (member_id) REFERENCES members(id)
)
""")
connection.commit()
Page 10 of 23
cursor.execute("SELECT * FROM members WHERE email = %s AND password =
%s", (email, password))
result = cursor.fetchone()
return result
Page 11 of 23
def search_book(connection, title):
cursor = connection.cursor()
cursor.execute("SELECT * FROM books WHERE title LIKE %s", ("%" + title +
"%",))
results = cursor.fetchall()
return results
def main():
connection = create_connection()
create_tables(connection)
while True:
print("Welcome to the Library Management System!")
print("1. Member Login")
print("2. Admin Login")
print("3. Register Member")
print("4. Exit")
if choice == "1":
email = input("Enter your email: ")
password = input("Enter your password: ")
member = login_member(connection, email, password)
if member:
print("Login successful!")
while True:
print("Member Menu:")
print("1. Borrow a Book")
print("2. Return a Book")
print("3. Search for a Book")
print("4. Exit")
Page 12 of 23
choice = input("Enter your choice: ")
if choice == "1":
book_id = int(input("Enter book ID: "))
borrow_date = input("Enter borrow date (YYYY-MM-DD): ")
return_date = input("Enter return date (YYYY-MM-DD): ")
borrow_book(connection, book_id, member[0], borrow_date,
return_date)
else:
print("Invalid choice. Please try again.")
else:
print("Invalid email or password. Please try again.")
Page 13 of 23
elif choice == "2":
username = input("Enter your username: ")
password = input("Enter your password: ")
admin = login_admin(connection, username, password)
if admin:
print("Login successful!")
while True:
print("Admin Menu:")
print("1. Add a Book")
print("2. Remove a Book")
print("3. View all Borrowings")
print("4. Exit")
if choice == "1":
title = input("Enter book title: ")
author = input("Enter book author: ")
publication_date = input("Enter publication date (YYYY-MM-DD): ")
cursor = connection.cursor()
cursor.execute("INSERT INTO books (title, author, publication_date)
VALUES (%s, %s, %s)", (title, author, publication_date))
connection.commit()
print("Book added successfully!")
Page 14 of 23
elif choice == "3":
cursor = connection.cursor()
cursor.execute("SELECT * FROM borrowings")
results = cursor.fetchall()
if results:
for result in results:
print(result)
else:
print("No borrowings found.")
else:
print("Invalid choice. Please try again.")
else:
print("Invalid username or password. Please try again.")
else:
print("Invalid choice. Please try again.")
Page 15 of 23
if __name__ == "__main__":
main()
Page 16 of 23
OUTPUT
• MEMBERS MENU
Page 17 of 23
Page 18 of 23
• ADMINS MENU
Page 19 of 23
Page 20 of 23
• NEW USER REGISTRATION
Page 21 of 23
SOFTWARE REQUIREMENT
• Windows OS
• Python
• MySQL
Page 22 of 23
CREDITS
• Few suggestions from subject teacher, Mrs. Kiran Singh
• Computer science With Python - Class XII By : Sumita
Arora
• www.geeksforgeeks.org
Page 23 of 23