0% found this document useful (0 votes)
36 views23 pages

Ilovepdf Merged (1)

Uploaded by

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

Ilovepdf Merged (1)

Uploaded by

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

COMPUTER SCIENCE

Digital Library

Name : V.KARUNYA
Roll Number :
Grade XII
Submitted Date :

SUBMITTED TO: SUBMITTED BY


Certificate

This Is To Certify That Karunya V Of Class 12 Has Completed


The Computer Science Project In Partial Fulfillment Of The
Curriculum Of CENTRAL BOARD OF SECONARY
EDUCATION (CBSE). This Project Was Carried Out In The
Laboratory Of Brainy Blooms L’École Internationale Senior
Secondary CBSE School , Thirukkanur Puducherry During
The Academic Year 2024-2025

INTERNAL EXAMINER EXTERNAL EXAMINER


Acknowledgement

I Would Wish To Express My Sincere Thanks To My Computer


Science Guide Mrs. NOORJAHAN M.C.A.,B.Ed.., for Her
valuable support and guidance throughout the execution of this
wonderful project in Computer Science.

I am very much grateful to my excellent school Brainy Blooms


L’École Internationale Senior Secondary CBSE School,
Thirukkanur Puducherry for providing me the necessary
platform to carry out the project successfully.

I would also wish to acknowledge the help received from my


dear classmates and my family members for their continuous
encouragement and moral support.
TABLE OF CONTENTS

S.No. Topic Page No.


1 Certificate 1
2 Acknowledgement 2
Hardwares and Softwares
3 3
Required
4 Introduction 5
5 Python Source Code 10
6 MySQL Database 45
7 Outputs 48
8 References 56

4|Page
INTRODUCTION
The project LIBRARY MANAGEMENT SYSTEM (DIGITAL
LIBRARY) includes enrolment of users, adding of books into
the library system. The software has the facility to search for
news, Wikipedia articles. It includes an authentication
facility for admin and user to login into the admin panel and
user panel resp. of the system. User can see the books
available, details of books issued by the user in the digital
library. The Library Management System can be login using a
user ID and password. It is accessible either by an admin or
user. Only the admin can add, delete and update the data of
users and books into the database. The data can be
retrieved easily.
The interface is very user-friendly. The data are well
protected for personal use and makes the data processing
very fast.
The purpose of the project entitled as “DIGITAL LIBRARY” is
to computerize the Front Library Management to develop
software which is user friendly, simple, fast, and cost-
effective. It also has a notes facility where the user can add
notes at any point of the program into the database.

5|Page
LIBRARY MANAGEMENT SYSTEM
(DIGITAL LIBRARY)
Library management system (LMS), is an enterprise resource
planning system for a library, used to track enrolled users,
available books, books issued and to whom, books returned
and it’s fines, etc.
The purpose of a library management system is to operate a
library with efficiency and at reduced costs. The system being
entirely automated streamlines all the tasks involved in
operations of the library.
The library management system software helps in reducing
operational costs. Managing a library manually is labour
intensive and an immense amount of paperwork is involved.
The system saves time for both the user and the librarian.
With just a click the user can search for the books available
in the library. The librarian can answer queries with ease
regarding the availability of books. Adding, removing or
editing the database is a simple process. Adding new users
or cancelling existing userships can be done with ease.
The automated system saves a considerable amount of time
as opposed to the manual system.

7|Page
Python Source
Code

10 | P a g e
1 # Importing necessary libraries
2 import mysql.connector
3 import pyfiglet
4 import requests
5 import wikipediaapi
6 from datetime import datetime
7
8
9 # Connect to the MySQL database
10 db = mysql.connector.connect(
11 host="localhost",
12 user="root",
13 password="admin",
14 database="library",
15 )
16 c = db.cursor()
17
18
19 # Function to display the return policy information
20 def returnPolicy():
21 print("Return Policy : ")
22 print("The issued book should be returned within 14 days(2 weeks).")
23 print(
24 "If the user kept the issued book for more than 14 days, then the
25 user have to pay ₹5 as fine for each extra day the user kept the issued
26 book."
27 )
28 print(" ")
29
30
31 # Function to calculate the length of a given integer after converting it
32 to a string
33 def length(i):
34 s = str(i)
35 length = len(s) + 2
36
37 return length
38
39
40 # Function to display a message for an invalid option
41 def validOption():
42 print("Please enter a valid option!")
43 print(" ")
44
45
46 # Function to handle program exit
47 def exiting():
48 print("\033[3;34m--------------------------\033[0;0m")
49 print("\033[3;33mExiting the program.")
50 print("Thank You!\033[0;0m")
51 print("\033[3;34m--------------------------\033[0;0m")
52 exit()
53
54
55 # Function to display the user menu and handle user choices
56 def userMenu():
57 # Displaying options for the user
58 print("1. Add Note")
59 print("2. Home")
60 print("3. Back")
61 print("4. Exit")
62 # Taking user choice as input
63 userChoice = int(input("Enter your Choice to Continue : "))
64 print(" ")
65
66 # Handle user choices

11 | P a g e
67 if userChoice == 1:
68 addNote()
69 elif userChoice == 2:
70 home()
71 elif userChoice == 3:
72 user()
73 elif userChoice == 4:
74 exiting()
75 else:
76 validOption()
77
78
79 # Function to display information about the library
80 def aboutLibrary():
81 # Retrieve the name of the librarian who is also an admin
82 c.execute("SELECT userName FROM users WHERE adminStatus='admin'")
83 userName = c.fetchall()
84
85 # Retrieve the total number of books and users in the library
86 c.execute("SELECT * FROM books")
87 totalBooks = c.fetchall()
88
89 c.execute("SELECT * FROM users")
90 totalUsers = c.fetchall()
91 db.commit()
92
93 print(" ")
94 print("About Library")
95 print(" ")
96 # Display library information
97 print("Year of Library's Establishment : ", 2023)
98 print("Name of the Librarian : ", userName[0][0])
99 print("Total Number of Books Available in the Library : ",
100 len(totalBooks))
101 print("Total Number of Users Enrolled in the Library : ",
102 len(totalUsers))
103 print(" ")
104 userMenu()
105
106
107 # Function to display the list of books in the library
108 def displayBooks():
109 print(" ")
110 print("Display Books")
111 print(" ")
112 # Retrieve all books from the database
113 c.execute("SELECT * FROM books ORDER BY bookId")
114 result = c.fetchall()
115 db.commit()
116
117 # Display books if available, otherwise notify the user
118 if result:
119 print("Books available in the Digital Library are :")
120 print(" ")
121 i = 0
122 for row in result:
123 i += 1
124 r = length(i)
125 print(f"{i}. Book ID : {row[0]}")
126 print(" " * r + f"Book Name : {row[1]}")
127 print(" " * r + f"Publication Year :
128 {row[2]}") print(" " * r + f"Author Name :
129 {row[7]}")
130 print(" " * r + f"Issue Status : {row[8]}")
131 print("--------------------------")
132 userMenu()
else:

12 | P a g e
133 # Notify the user if no books are found
134 print("No books found.")
135 print("--------------------------")
136 userMenu()
137
138
139 # Search books menu options
140 def searchBooksMenu():
141 print("1. Add Note")
142 print("2. Home")
143 print("3. Back")
144 print("4. Exit")
145 userChoice = int(input("Enter your Choice to Continue : "))
146
147 # User choices handling
148 if userChoice == 1:
149 addNote()
150 elif userChoice == 2:
151 home()
152 elif userChoice == 3:
153 searchBooks()
154 elif userChoice == 4:
155 exiting()
156 else:
157 validOption()
158
159
160 # Function to search books by Book ID
161 def searchBooksbyId():
162 print(" ")
163 print("Search Books by Book ID")
164 print(" ")
165 # Get user input for Book ID
166 bookId = int(input("Enter the Book ID to search the Book : "))
167 print(" ")
168
169 # Execute SQL query to retrieve book information by Book ID
170 c.execute("SELECT * FROM books WHERE bookId=%s", (bookId,))
171 result = c.fetchall()
172 db.commit()
173
174 # Display search results if books are found, otherwise notify the user
175 if result:
176 print(f'Book available in the Digital Library with the Book ID
177 "{bookId}" is :')
178 print(" ")
179 i = 0
180 for row in result:
181 i += 1
182 r = length(i)
183 print(f"{i}. Book ID : {row[0]}")
184 print(" " * r + f"Book Name : {row[1]}")
185 print(" " * r + f"Publication Year :
186 {row[2]}") print(" " * r + f"Author Name :
187 {row[7]}")
188 print(" " * r + f"Issue Status : {row[8]}")
189 print("--------------------------")
190 searchBooksMenu()
191 else:
192 print(f'No book found with the book id "{bookId}".')
193 print(" ")
194 searchBooksMenu()
195
196
197 # Function to search books by keyword
198 def searchBooksbyKeyword():
print(" ")

13 | P a g e
199 print("Search Books by Keyword")
200 print(" ")
201 # Get user input for keyword
202 keyword = input("Enter a Keyword to search Books : ")
203 print(" ")
204
205 # Execute SQL query to retrieve books by keyword
206 c.execute(
207 "SELECT * FROM books WHERE bookName LIKE '%{}%' ORDER BY
208 bookId".format(keyword)
209 )
210 result = c.fetchall()
211 db.commit()
212
213 # Display search results if books are found, otherwise notify the user
214 if result:
215 print(
216 f'Books available in the Digital Library with the Keyword
217 "{keyword}" are :'
218 )
219 print(" ")
220 i = 0
221 for row in result:
222 i += 1
223 r = length(i)
224 print(f"{i}. Book ID : {row[0]}")
225 print(" " * r + f"Book Name : {row[1]}")
226 print(" " * r + f"Publication Year :
227 {row[2]}") print(" " * r + f"Author Name :
228 {row[7]}")
229 print(" " * r + f"Issue Status : {row[8]}")
230 print("--------------------------")
231 searchBooksMenu()
232 else:
233 print(f'No books found with the keyword "{keyword}".')
234 print(" ")
235 searchBooksMenu()
236
237
238 # Function to display search options for books
239 def searchBooks():
240 print(" ")
241 print("Search Books")
242 print(" ")
243 print("1. Search by Book ID")
244 print("2. Search by Keyword")
245 print("3. Home")
246 print("4. Back")
247 print("5. Exit")
248 userChoice = int(input("Enter your Choice to Continue : "))
249 print(" ")
250
251 # User choices handling
252 if userChoice == 1:
253 searchBooksbyId()
254 elif userChoice == 2:
255 searchBooksbyKeyword()
256 elif userChoice == 3:
257 home()
258 elif userChoice == 4:
259 user()
260 elif userChoice == 5:
261 exiting()
262 else:
263 validOption()
264

14 | P a g e
265 # Function to display the add book menu and handle user choices
266 def addBookMenu():
267 # Add book menu options
268 print("1. Home")
269 print("2. Back")
270 print("3. Exit")
271 userChoice = int(input("Enter your Choice to Continue : "))
272 print(" ")
273
274 # User choices handling
275 if userChoice == 1:
276 home()
277 elif userChoice == 2:
278 modifyBook()
279 elif userChoice == 3:
280 exiting()
281 else:
282 validOption()
283
284
285 # Function to add a new book to the library
286 def addBook():
287 print(" ")
288 print("Add Book")
289 print(" ")
290 # Get user input for book details
291 bookId = int(input("Enter the Book ID : "))
292 bookName = input("Enter the Book Name : ")
293 publicationYear = int(input("Enter the Book Publication Year : "))
294 author = input("Enter the Book Author Name : ")
295 print(" ")
296
297 c.execute("SELECT bookId FROM books")
298 result = c.fetchall()
299 db.commit()
300
301 if (bookId,) in result:
302 print(
303 f'The book of book id "{bookId}" is already available in the
304 digital library.'
305 )
306 print(" ")
307 addBookMenu()
308 else:
309 # Execute SQL query to insert the new book into the database
310 c.execute(
311 "INSERT INTO books (bookId, bookName, publicationYear, author)
312 VALUES (%s, %s, %s, %s)",
313 (bookId, bookName, publicationYear, author),
314 )
315 db.commit()
316
317 # Notify the user that the book has been added successfully
318 print("Book added Successfully!")
319 print(" ")
320 addBookMenu()
321
322
323 # Function to display the delete book menu and handle user choices
324 def deleteBookMenu():
325 # Delete book menu options
326 print("1. Home")
327 print("2. Back")
328 print("3. Exit")
329 userChoice = int(input("Enter your Choice to Continue : "))
330 print(" ")

15 | P a g e
2179 elif userChoice == 8:
2180 home()
2181 elif userChoice == 9:
2182 authUser()
2183 elif userChoice == 10:
2184 exiting()
2185 else:
2186 validOption()
2187
2188
2189 # Function to display the main menu
2190 def home():
2191 while True:
2192 print("==========================")
2193 print("\033[1;32m~~~~~~~~~~~~~~~~~~~~~~~~~~\033[0;0m")
2194 print(
2195 "\033[1;31m"
2196 + pyfiglet.figlet_format("Welcome to the", font="banner3",
2197 width=1000)
2198 )
2199 print(
2200 pyfiglet.figlet_format("Digital Library", font="banner3",
2201 width=1000)
2202 + "\033[0;0m"
2203 )
2204 print("\033[1;32m~~~~~~~~~~~~~~~~~~~~~~~~~~\033[0;0m")
2205 print("==========================")
2206 print(" ")
2207 print("Home")
2208 print(" ")
2209 print("1. Admin")
2210 print("2. User")
2211 print("3. Exit")
2212 userChoice = int(input("Enter your Choice to Continue : "))
2213 print(" ")
2214
2215 # Handle user choices
2216 if userChoice == 1:
2217 authAdmin()
2218 elif userChoice == 2:
2219 authUser()
2220 elif userChoice == 3:
2221 exiting()
2222 else:
2223 validOption()
2224
2225
2226 # Call the main menu function
2227 home()
2228
2229

44 | P a g e
MySQL
Database

45 | P a g e
Library Database:

Books Table:

Users Table:

46 | P a g e
Notes Table:

Issued Books Details Table:

47 | P a g e
Outputs

48 | P a g e
Starting of the program:

Admin Authentication:

Adding a new user:

49 | P a g e
Updating user details:

Adding a new book:

50 | P a g e
Updating book details:

51 | P a g e
User Authentication:

About Library:

52 | P a g e
News:

Wikipedia Articles:

53 | P a g e
Issued Books Details:

54 | P a g e

You might also like