0% found this document useful (0 votes)
8 views72 pages

Library Management System Project Report

The document certifies that students Alisha, Fatema, and Rafat from Meerut Public School completed a project on a Library Management System under the guidance of Mr. Kuldeep Goswami. It outlines the project's objectives, development phases, and challenges faced, emphasizing the use of Python and MySQL for automating library operations. The project aims to enhance efficiency in managing library resources through features like user enrollment, book management, and fine tracking.
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)
8 views72 pages

Library Management System Project Report

The document certifies that students Alisha, Fatema, and Rafat from Meerut Public School completed a project on a Library Management System under the guidance of Mr. Kuldeep Goswami. It outlines the project's objectives, development phases, and challenges faced, emphasizing the use of Python and MySQL for automating library operations. The project aims to enhance efficiency in managing library resources through features like user enrollment, book management, and fine tracking.
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

SUBMITTED TO- MR.

SUBMITTED BY:Alisha,
KULDEEP GOSWAMI Fatema, &Rafat
SIR SGoswamiSir
Class: XII - 'E' & 'C'
Certificate

This is to certify that Alisha, Fatema, and Rafat,


students of class XII-'E' and 'C' of Meerut Public
School, have successfully completed the Project
work under the guidance of Mr. Kuldeep Goswami
(subject teacher) during the year 2025-26.

Internal examiner’s External examiner’s


Signature Signature
________________ ________________

Page 1
Declaration

We hereby declare that the Project work submitted


to the Department of Informatics Practices by us is
the result of our personal effort. All the Python
coding and project report is our original work.

Names: Alisha, Fatema, Rafat


Class: XII - 'E' and 'C'
RollNo.:

Page 2
Acknowledgement

We would like to express our special thanks of gratitude


to our teacher Mr. Kuldeep Goswami, who gave us the
golden opportunity to work on this wonderful project.
This project also helped us in doing a lot of research and
we came to know about so many new things. We are
really thankful to him.

We also want to thank our families for their support and


motivation throughout the making of this project

Names: Alisha, Fatema, Rafat


Class: XII - 'E' and 'C'
RollNo.:

Page 3
Table of content
[Link]. Contents PageNo.
1. Certificate 1
2. Declaration 2
3. Acknowledgement 3
4. Project Introduction 5
5. Project Goals 8
6. Development Phase :Trials and Errors 12
7. Data Collection 16
8. Python Source Code 20
9. MY SQL Database 55
10. Output 58
11. System Requirements 66
12. Future Scope 68
13. Conclusion 70
14. Bibliography 71

Page 4
Project Introduction

Project Overview
 The Library Management System project is designed to
create a comprehensive, efficient, and user-friendly digital
platform that automates the traditional manual processes of
managing a library. Utilizing the power of Python
programming language combined with the robust data
handling capabilities of MySQL, this system aims to
streamline the core functions of a library, including user
enrolment, book management, issuing and returning of
books, and fine tracking.
 The system is intended to serve as a centralized solution for
librarians and users alike, providing an intuitive interface
for managing library resources and user activities. By
automating these processes, the project seeks to reduce
human error, improve data accuracy, and enhance the
overall efficiency of library operations.
 This project will also incorporate essential features such as
advanced search capabilities, allowing users to find books
quickly by ID, title, or keywords. It will maintain detailed
records of issued books, track due dates, and calculate fines
for late returns, ensuring accountability and timely returns.
Additionally, the system will support secure login
mechanisms for both administrators and users,

Page 5
safeguarding sensitive data and restricting unauthorized
access.

Key Objectives
The primary objectives of this project are as follows:

 To develop a reliable user enrolment module that allows


new users to register and existing users to manage their
accounts seamlessly.
 To implement a dynamic book management system
enabling the addition, updating, and deletion of book
records in the library database with ease.
 To facilitate the issuing and returning of books, including
the automatic calculation of fines based on return dates,
thereby promoting timely returns and accountability.
 To provide a powerful search functionality that allows
users to locate books efficiently using various parameters
such as book ID, title, or keywords.
 To display comprehensive details of available books and
issued books, offering clear visibility into the library's
inventory and lending status.
 To ensure robust security through secure login protocols for
both administrators and users, protecting the system from
unauthorized access and potential data breaches.

Page 6
Scope and Limitations
 This project is focused on automating the core operations
of a library using Python and MySQL technologies. It aims
to replace manual record-keeping with an automated
system that enhances accuracy, speed, and user
convenience.
 The scope includes user management, book inventory
control, book issuing and returning processes, fine
calculation, and search functionalities. The system will be
designed primarily for desktop use, targeting library staff
and users accessing the system through a local network or
standalone setup.
 However, the project has certain limitations. It does not
encompass advanced features such as cloud integration,
which would allow remote access and data synchronization
across multiple devices. Mobile application support is also
outside the scope of this project, limiting accessibility to
desktop environments. Furthermore, the system does not
include features like automated notifications for due dates
or integration with external library networks.
 Despite these limitations, the project provides a solid
foundation for library automation and can be extended in
the future to incorporate more advanced functionalities as
needed.

Page 7
Project Goals

Visualizing Library Data


 One of the primary goals of the Library Management
System is to provide a comprehensive visualization of all
library-related data. This includes detailed displays of
books available in the library, registered users, and the
status of issued books. The system will present this
information in an organized and user-friendly manner,
using tables and lists that allow librarians and users to
quickly assess the current state of the library's inventory
and lending activities. Visualization aids in efficient
decision-making, such as identifying popular books,
monitoring overdue returns, and managing inventory levels.

Managing Users
 Effective user management is critical to the smooth
operation of the library. The system aims to facilitate the
addition of new users, updating existing user information,
deleting users who are no longer active, and searching for
users based on various criteria such as user ID, name, or
membership status. This module ensures that user data is
accurate and up-to-date, enabling personalized services and
maintaining accountability for borrowed materials.

Page 8
Managing Books
 The book management module is designed to handle the
entire lifecycle of library books. This includes adding new
books to the database, updating details such as title, author,
and publication year, deleting outdated or damaged books,
and searching for books using multiple parameters like
book ID, title keywords, or author names. This
functionality ensures that the library's collection is well-
maintained, relevant, and easily accessible to users.

Issuing and Returning Books


 A core function of the system is to manage the issuing and
returning of books. This involves tracking the dates when
books are issued and returned, calculating fines for late
returns, and updating the status of books accordingly. The
system will automate fine calculations based on predefined
rules, reducing manual errors and ensuring fairness. It will
also generate alerts or notifications for overdue books,
helping librarians enforce timely returns and maintain the
availability of resources.

Page 9
Authentication
 Security is paramount in managing sensitive library data.
The system will implement secure login mechanisms for
both administrators and users. This includes password
protection, role-based access control, and session
management to prevent unauthorized access.
Authentication ensures that only authorized personnel can
perform administrative tasks such as adding or deleting
books and users, while regular users can access their
accounts and perform permitted actions securely.

Reporting and Analytics


 The system aims to provide comprehensive reporting and
analytics features that help library administrators monitor
usage patterns, identify trends, and make data-driven
decisions. Reports may include monthly borrowing
statistics, user activity logs, and inventory turnover rates.

Backup and Recovery


 To safeguard against data loss, the system will incorporate
backup and recovery mechanisms. Regular automated

Page 10
backups will be scheduled, and procedures for restoring
data in case of system failures will be established.

User Support and Help


 The project will include a help module or user guide to
assist users and administrators in navigating the system,
troubleshooting common issues, and understanding system
functionalities.

Scalability and Maintainability


 The system will be designed with scalability in mind,
allowing for future expansion to accommodate growing
user bases and additional features. Maintainable code
practices and modular design will facilitate easy updates
and enhancements.

Page 11
Development Phase : Trials and Errors

Data Loading and Cleaning


 The initial phase of the development process focused
heavily on data loading and cleaning, which proved to be a
critical foundation for the entire Library Management
System. The project team began by designing the database
schema in MySQL, creating tables for books, users, and
issued book details. However, during the initial data
import, several challenges emerged. Missing data fields,
inconsistent formatting, and duplicate entries were common
issues that threatened the integrity of the database.
 To address these problems, the team implemented rigorous
data validation routines. Scripts were written in Python to
scan for null or malformed entries and to enforce
constraints such as unique book IDs and valid user
information. This cleaning process was iterative, requiring
multiple passes to refine the data quality. For example,
book titles were standardized to avoid discrepancies caused
by case sensitivity or extra whitespace.
 Additionally, the team developed automated scripts to
handle bulk data imports, ensuring that large datasets could
be integrated efficiently without manual intervention.
These scripts included error logging mechanisms to capture
and report anomalies, facilitating prompt corrections.

Page 12
Data Analysis and Query Design
 Once the database was populated with clean and reliable
data, the next step involved designing SQL queries to
support the system's core functionalities. This phase was
marked by extensive trial and error as the team
experimented with different query structures to optimize
performance and accuracy.

 Complex queries were developed to enable flexible search


capabilities, allowing users to find books by ID, title
keywords, author names, or publication years. The team
faced challenges in balancing query complexity with
execution speed, especially when dealing with large
datasets. Indexing strategies were tested and refined to
improve retrieval times.
 Fine calculation logic was another area of focus. The team
designed queries to compute fines based on the difference
between the current date and the book's due date,
incorporating rules for grace periods and maximum fine
limits. Handling edge cases such as leap years and holidays
required additional logic and testing.

Visualization and User Interface


 To make the system accessible and user-friendly, the team
developed a menu-driven interface using Python. This
interface presented data in clear, tabular formats, making it

Page 13
easy for librarians and users to navigate book lists, user
details, and issued book records.
 Feedback from initial users highlighted areas for
improvement, such as clearer prompts and error messages.
The team iteratively refined the interface, enhancing input
validation and adding features like pagination for long lists.

Performance Optimization
 Performance issues surfaced during testing, particularly
with slow query responses and delays in data display. To
mitigate these, the team implemented indexing on
frequently searched columns such as book ID and user ID,
which significantly reduced query execution times.
 Query optimization techniques were applied, including
limiting result sets, avoiding unnecessary joins, and
caching frequently accessed data. These improvements
contributed to a smoother user experience and more
efficient system operation.

Trial and Error in Development


 The development process was characterized by continuous
cycles of trial and error, testing, and refinement. One
notable challenge was the implementation of the fine
calculation module. Initial versions failed to account for all
possible date scenarios, leading to incorrect fine amounts.
Through debugging and consultation of date-handling

Page 14
libraries, the team developed a robust solution that
accurately calculates fines under various conditions.
 The user authentication module also underwent multiple
revisions. Early implementations lacked sufficient security
measures, prompting the integration of hashed passwords
and session management to protect user data.
 Other challenges included handling concurrent book issues
and returns, ensuring data consistency, and managing error
states gracefully. Each issue was addressed through
iterative coding, testing, and feedback incorporation,
resulting in a stable and reliable system.

Page 15
Data Collection

Introduction to Data Collection


Data collection is a fundamental phase in the development of the
Library Management System, serving as the backbone for all
subsequent operations. This phase involves gathering,
organizing, and preparing data related to books, users, and
issued transactions to ensure the system functions accurately and
efficiently. The quality and comprehensiveness of the collected
data directly impact the system's reliability, user experience, and
overall success.

Sources of Data
The data for this project was sourced from multiple channels to
create a robust and representative dataset:

 Manual Entry by Library Staff: Initial data entry was


performed by library administrators who input user
registrations, book details, and transaction records. This
method ensured that the data reflected the current state of
the library.
 Digitized Legacy Records: Historical records maintained
in physical or legacy digital formats were digitized and
imported into the MySQL database. This process involved

Page 16
scanning, transcription, and verification to preserve data
integrity.
 User Feedback and Audits: Ongoing updates and
corrections were incorporated based on feedback from
users and periodic audits conducted by the library staff to
maintain data accuracy.

Data Types and Formats


The data collected was structured into specific formats to
facilitate efficient storage and retrieval:

 Books Data: Included fields such as Book ID (unique


identifier), Title, Author, Publication Year, Genre,
Publisher, and Availability Status. This data was stored in a
relational table with constraints to prevent duplication and
ensure consistency.
 User Data: Comprised User ID, Full Name, Contact
Information, Membership Type (e.g., student, faculty),
Account Status, and Borrowing History. This information
was critical for managing user privileges and tracking
borrowing activities.
 Issued Books Data: Recorded transactional details
including Issue ID, Book ID, User ID, Issue Date, Due
Date, Return Date, and Fine Amount. This data was
essential for monitoring book circulation and enforcing
library policies.

Page 17
Data Collection Methodology
The methodology adopted for data collection emphasized
accuracy, consistency, and completeness:

 Validation Checks: Automated scripts and manual reviews


were used to validate data entries, ensuring fields were
correctly filled and adhered to predefined formats.
 Standardization: Text fields were standardized to
maintain uniformity, such as consistent capitalization of
book titles and author names, and removal of extraneous
spaces or special characters.
 Referential Integrity: Relationships between tables were
enforced through foreign key constraints, linking issued
books to valid user and book records.
 Incremental Updates: The system supported incremental
data updates to accommodate new entries, modifications,
and deletions without disrupting existing data.

Challenges Encountered
Several challenges arose during the data collection phase,
requiring careful attention and problem-solving:

 Incomplete Records: Some legacy data lacked complete


information, necessitating manual verification and
supplementation from physical archives.

Page 18
 Inconsistent Formats: Variations in data formats,
especially from digitized sources, required extensive
cleaning and normalization.
 Duplicate Entries: Identifying and resolving duplicate
records was critical to prevent data redundancy and ensure
accurate reporting.
 Data Entry Errors: Manual entry introduced
typographical errors and inconsistencies, which were
mitigated through validation scripts and user training.

Tools and Technologies Used


To facilitate efficient data collection and preparation, the
following tools and technologies were employed:

 MySQL Database Management System: Provided a


structured environment for storing and managing relational
data with support for constraints and indexing.
 Python Scripts: Automated data validation, cleaning, and
bulk import processes, reducing manual workload and
minimizing errors.
 Spreadsheet Software: Used for initial data organization,
review, and manual corrections before importing into the
database.

Page 19
PYTHON
SOURCE
CODE

Page 20
1 #Importingnecessarylibraries
2 [Link]
3 importpyfiglet
4 importrequests
5 importwikipediaapi
6 fromdatetimeimportdatetime
7
8
9 #ConnecttotheMySQLdatabase
10 db= [Link](
11 host="localhost",
12 user="root",
13 password="admin",
14 database="library",
15 )
16 c=[Link]()
17
18
19 #Functiontodisplaythereturnpolicyinformation
20 defreturnPolicy():
21 print("ReturnPolicy:")
22 print("Theissuedbookshouldbereturnedwithin14days(2weeks).")
23 print(
24 "Iftheuserkepttheissuedbookformorethan14days,thenthe
25 userhavetopay₹5asfineforeachextradaytheuserkepttheissued
26 book."
27 )
28 print(" ")
29
30
31 #Functiontocalculatethelengthofagivenintegerafterconvertingit
32 toa string
33 deflength(i):
34 s=str(i)
35 length=len(s)+2
36
37 returnlength
38
39
40 #Functiontodisplayamessageforaninvalidoption
41 defvalidOption():
42 print("Pleaseenteravalidoption!")
43 print(" ")
44
45
46 #Functiontohandleprogramexit
47 defexiting():
48 print("\033[3;34m --------------------------\033[0;0m")
49 print("\033[3;33mExitingtheprogram.")
50 print("ThankYou!\033[0;0m")
51 print("\033[3;34m --------------------------\033[0;0m")
52 exit()
53
54
55 #Functiontodisplaytheusermenuandhandleuserchoices
56 defuserMenu():
57 #Displayingoptionsfortheuser
58 print("[Link]")
59 print("[Link]")
60 print("[Link]")
61 print("[Link]")
62 #Takinguserchoiceasinput
63 userChoice=int(input("EnteryourChoicetoContinue:"))
64 print(" ")
65
66 #Handleuserchoices

21|Page
67 ifuserChoice==1:
68 addNote()
69 elifuserChoice==2:
70 home()
71 elifuserChoice==3:
72 user()
73 elifuserChoice==4:
74 exiting()
75 else:
76 validOption()
77
78
79 #Functiontodisplayinformationaboutthelibrary
80 defaboutLibrary():
81 # Retrieve the name of the librarian who is also an admin
82 [Link]("SELECTuserNameFROMusersWHEREadminStatus='admin'") userName
83 = [Link]()
84
85 #Retrievethetotalnumberofbooksandusersinthelibrary
86 [Link]("SELECT*FROMbooks")
87 totalBooks = [Link]()
88
89 [Link]("SELECT*FROMusers")
90 totalUsers = [Link]()
91 [Link]()
92
93 print(" ")
94 print("AboutLibrary")
95 print(" ")
96 #Displaylibraryinformation
97 print("Year of Library's Establishment : ", 2023)
98 print("Name of the Librarian : ", userName[0][0])
99 print("TotalNumberofBooksAvailableintheLibrary:",
100 len(totalBooks))
101 print("TotalNumberofUsersEnrolledintheLibrary:", len(totalUsers))
102 print(" ")
103 userMenu()
104
105
106 #Functiontodisplaythelistofbooksinthelibrary
107 defdisplayBooks():
108 print(" ")
109 print("DisplayBooks")
110 print(" ")
111 # Retrieve all books from the database
112 [Link]("SELECT*FROMbooksORDERBYbookId") result =
113 [Link]()
114 [Link]()
115
116 #Displaybooksifavailable,otherwisenotifytheuser
117 ifresult:
118 print("BooksavailableintheDigitalLibraryare:")
119 print(" ")
120 i=0
121 forrowinresult: i
122 += 1
123 r=length(i)
124 print(f"{i}.BookID:{row[0]}")
125 print(""* r + f"Book Name : {row[1]}")
126 print(""*r+f"PublicationYear:{row[2]}")
127 print(""* r + f"Author Name : {row[7]}")
128 print(""*r+f"IssueStatus:{row[8]}") print("
129 ---------------------------------")
130 userMenu()
131 else:
132

22|Page
133 #Notifytheuserifnobooksarefound
134 print("Nobooksfound.")
135 print(" --------------------------")
136 userMenu()
137
138
139 #Searchbooksmenuoptions
140 def searchBooksMenu():
141 print("[Link]")
142 print("2. Home")
143 print("[Link]")
144 print("[Link]")
145 userChoice=int(input("EnteryourChoicetoContinue:"))
146
147 #Userchoiceshandling
148 ifuserChoice==1:
149 addNote()
150 elifuserChoice==2:
151 home()
152 elifuserChoice==3:
153 searchBooks()
154 elifuserChoice==4:
155 exiting()
156 else:
157 validOption()
158
159
160 #FunctiontosearchbooksbyBook ID
161 defsearchBooksbyId():
162 print(" ")
163 print("Search Books by Book ID")
164 print(" ")
165 #GetuserinputforBookID
166 bookId=int(input("EntertheBookIDtosearchtheBook:")) print(" ")
167
168 #ExecuteSQLquerytoretrievebookinformationbyBookID
169 [Link]("SELECT*FROMbooksWHEREbookId=%s",(bookId,))
170 result = [Link]()
171 [Link]()
172
173 #Displaysearchresultsifbooksarefound,otherwisenotifytheuser
174 ifresult:
175 print(f'BookavailableintheDigitalLibrarywiththeBookID "{bookId}"
176 is :')
177 print(" ")
178 i=0
179 forrowinresult: i
180 += 1
181 r=length(i)
182 print(f"{i}.BookID:{row[0]}")
183 print(""* r + f"Book Name : {row[1]}")
184 print(""*r+f"PublicationYear:{row[2]}")
185 print(""* r + f"Author Name : {row[7]}")
186 print(""*r+f"IssueStatus:{row[8]}") print("
187 ---------------------------------")
188 searchBooksMenu()
189 else:
190 print(f'Nobookfoundwiththebookid"{bookId}".')
191 print(" ")
192 searchBooksMenu()
193
194
195 #Functiontosearchbooksbykeyword
196 defsearchBooksbyKeyword():
197 print(" ")
198

23|Page
199 print("Search Books by Keyword")
200 print(" ")
201 #Getuserinputforkeyword
202 keyword=input("EnteraKeywordtosearchBooks:") print("
203 ")
204
205 #ExecuteSQLquerytoretrievebooksbykeyword
206 [Link](
207 "SELECT*FROMbooksWHEREbookNameLIKE'%{}%'ORDERBY
208 bookId".format(keyword)
209 )
210 result=[Link]()
211 [Link]()
212
213 #Displaysearchresultsifbooksarefound,otherwisenotifytheuser
214 ifresult:
215 print(
216 f'BooksavailableintheDigitalLibrarywiththeKeyword "{keyword}"
217 are :'
218 )
219 print(" ")
220 i=0
221 forrowinresult: i
222 += 1
223 r=length(i)
224 print(f"{i}.BookID:{row[0]}")
225 print(""* r + f"Book Name : {row[1]}")
226 print(""*r+f"PublicationYear:{row[2]}")
227 print(""* r + f"Author Name : {row[7]}")
228 print(""*r+f"IssueStatus:{row[8]}") print("
229 ---------------------------------")
230 searchBooksMenu()
231 else:
232 print(f'Nobooksfoundwiththekeyword"{keyword}".')
233 print(" ")
234 searchBooksMenu()
235
236
237 #Functiontodisplaysearchoptionsforbooks
238 defsearchBooks():
239 print(" ")
240 print("SearchBooks")
241 print(" ")
242 print("[Link]")
243 print("[Link]")
244 print("3. Home")
245 print("[Link]")
246 print("[Link]")
247 userChoice=int(input("EnteryourChoicetoContinue:")) print("
248 ")
249
250 #Userchoiceshandling
251 if userChoice == 1:
252 searchBooksbyId()
253 elif userChoice == 2:
254 searchBooksbyKeyword()
255 elifuserChoice==3:
256 home()
257 elifuserChoice==4:
258 user()
259 elifuserChoice==5:
260 exiting()
261 else:
262 validOption()
263
264

24|Page
265 #Functiontodisplaytheaddbookmenuandhandleuserchoices
266 defaddBookMenu():
267 #Addbookmenuoptions
268 print("[Link]")
269 print("[Link]")
270 print("[Link]")
271 userChoice=int(input("EnteryourChoicetoContinue:")) print("
272 ")
273
274 #Userchoiceshandling
275 ifuserChoice==1:
276 home()
277 elifuserChoice==2:
278 modifyBook()
279 elifuserChoice==3:
280 exiting()
281 else:
282 validOption()
283
284
285 #Functiontoaddanewbooktothelibrary
286 defaddBook():
287 print(" ")
288 print("AddBook")
289 print(" ")
290 #Getuserinputforbookdetails
291 bookId=int(input("EntertheBookID:")) bookName
292 = input("Enter the Book Name : ")
293 publicationYear=int(input("EntertheBookPublicationYear:")) author =
294 input("Enter the Book Author Name : ")
295 print(" ")
296
297 [Link]("SELECTbookIdFROMbooks") result
298 = [Link]()
299 [Link]()
300
301 if(bookId,)inresult: print(
302 f'Thebookofbookid"{bookId}"isalreadyavailableinthe digital
303 library.'
304 )
305 print(" ")
306 addBookMenu()
307 else:
308 #ExecuteSQLquerytoinsertthenewbookintothedatabase
309 [Link](
310 "INSERTINTObooks(bookId,bookName,publicationYear,author)
311 VALUES (%s, %s, %s, %s)",
312 (bookId,bookName,publicationYear,author),
313 )
314 [Link]()
315
316 #Notifytheuserthatthebookhasbeenaddedsuccessfully
317 print("Book added Successfully!")
318 print(" ")
319 addBookMenu()
320
321
322 #Functiontodisplaythedeletebookmenuandhandleuserchoices
323 defdeleteBookMenu():
324 #Deletebookmenuoptions
325 print("[Link]")
326 print("[Link]")
327 print("[Link]")
328 userChoice=int(input("EnteryourChoicetoContinue:")) print("
329 ")
330

25|Page
331
332 #Userchoiceshandling
333 ifuserChoice==1:
334 home()
335 elifuserChoice==2:
336 admin()
337 elifuserChoice==3:
338 exiting()
339 else:
340 validOption()
341
342
343 #Functiontodeleteabookfromthelibrary
344 defdeleteBook():
345 print(" ")
346 print("DeleteBook")
347 print(" ")
348 #GetuserinputforthebookIDtobedeleted
349 bookId=int(input("EntertheBookID:"))
350 choice=input("AreyousuretodeletetheBook?(Yes/No):") print(" ")
351
352 [Link]("SELECTbookIdFROMbooks") result
353 = [Link]()
354 [Link]()
355
356 [Link]()in["yes","y"]: if
357 (bookId,) in result:
358 # Execute SQL query to delete the book from the database
359 [Link]("DELETEFROMbooksWHEREbookId=%s",(bookId,))
360 [Link]()
361
362 #Notifytheuserthatthebookhasbeendeletedsuccessfully
363 print("BookdeletedSuccessfully!")
364 print(" --------------------------")
365 deleteBookMenu()
366 else:
367 print(
368 f'Thebookofbookid"{bookId}"doesnotavailableinthe digital
369 library.'
370 )
371 print(" --------------------------")
372 deleteBookMenu()
373 elif [Link]() in ["no", "n"]:
374 print(" ")
375 print("BookNotDeleted!")
376 print(" --------------------------")
377 deleteBookMenu()
378 else:
379 validOption()
380
381
382 #Updatebookmenuoptions
383 defupdateBookMenu():
384 print("1. Home")
385 print("[Link]")
386 print("[Link]")
387 userChoice=int(input("EnteryourChoicetoContinue:")) print("
388 ")
389
390 #Userchoiceshandling
391 ifuserChoice==1:
392 home()
393 elifuserChoice==2:
394 updateUser()
395 elifuserChoice==3:
396

26|Page
397 exiting()
398 else:
399 validOption()
400
401
402 defnotBook(bookId):
403 print(f'Thebookofbookid"{bookId}"doesnotavailableinthe digital
404 library.')
405 print(" ")
406 updateBookMenu()
407
408
409 #Functiontoupdatebookdetails
410 defupdateBook():
411 print(" ")
412 print("Update Book Details")
413 print(" ")
414 print("1. Update the Book ID")
415 print("[Link]")
416 print("[Link]")
417 print("4. Update the Book Author Name")
418 print("5. Home")
419 print("[Link]")
420 print("[Link]")
421 userChoice=int(input("EnteryourChoicetoContinue:")) print("
422 ")
423
424 [Link]("SELECTbookIdFROMbooks") result
425 = [Link]()
426 [Link]()
427
428 #Userchoiceshandling
429 ifuserChoice==1:
430 currentBookId=int(input("EntertheCurrentBookID:")) newBookId =
431 int(input("Enter the New Book ID : "))
432
433 if(currentBookId,)inresult:
434 #ExecuteSQLquerytoupdatetheBook ID
435 [Link](
436 "UPDATEbooksSETbookId=%sWHEREbookId=%s",(newBookId,
437 currentBookId)
438 )
439 [Link]()
440
441 print("BookIDchangedSuccessfully!")
442 print(" --------------------------")
443 updateBookMenu()
444 else:
445 notBook(currentBookId)
446
447 elifuserChoice==2:
448 bookId = int(input("Enter the Book ID : "))
449 newBookName=input("EntertheNewBookName:")
450
451 if(bookId,)inresult:
452 #ExecuteSQLquerytoupdatetheBookName
453 [Link](
454 "UPDATEbooksSETbookName=%sWHEREbookId=%s", (newBookName,
455 bookId)
456 )
457 [Link]()
458
459 print("BookNamechangedSuccessfully!")
460 print(" --------------------------")
461 updateBookMenu()
462 else:

27|Page
463 notBook(bookId)
464
465 elifuserChoice==3:
466 bookId = int(input("Enter the Current Book ID : "))
467 newPublicationYear=input("EntertheNewPublicationYear:")
468
469 if(bookId,)inresult:
470 #ExecuteSQLquerytoupdatethePublicationYear
471 [Link](
472 "UPDATEbooksSETpublicationYear=%sWHEREbookId=%s",
473 (newPublicationYear, bookId),
474 )
475 [Link]()
476
477 print("BookPublicationYearchangedSuccessfully!")
478 print(" --------------------------")
479 updateBookMenu()
480
481 elifuserChoice==4:
482 bookId=int(input("EntertheCurrentBookID:")) newAuthor
483 = input("Enter the New Author Name : ")
484
485 if(bookId,)inresult:
486 #ExecuteSQLquerytoupdatetheAuthorName
487 [Link](
488 "UPDATEbooksSETauthor=%sWHEREbookId=%s",
489 (newAuthor, bookId),
490 )
491 [Link]()
492
493 print("BookAuthorNamechangedSuccessfully!")
494 print(" --------------------------")
495 updateBookMenu()
496 else:
497 notBook(bookId)
498
499 elifuserChoice==5:
500 home()
501 elifuserChoice==6:
502 modifyBook()
503 elifuserChoice==7:
504 exiting()
505 else:
506 validOption()
507
508
509 #Functiontodisplaytheissuebookmenuandhandleuserchoices
510 defissueBookMenu():
511 print("[Link]")
512 print("[Link]")
513 print("[Link]")
514 userChoice=int(input("EnteryourChoicetoContinue:")) print("
515 ")
516
517 #Userchoiceshandling
518 ifuserChoice==1:
519 home()
520 elifuserChoice==2:
521 admin()
522 elifuserChoice==3:
523 exiting()
524 else:
525 validOption()
526
527
528 #Functiontoissuea book

28|Page
529 def issueBook():
530 print(" ")
531 print("IssueBook")
532 print(" ")
533 bookId=int(input("EntertheBookIDtobeIssued:"))
534 userId=int(input("EntertheUserIDtowhomBookwillbeIssued:"))
535
536 #ExecuteSQLquerytochecktheissuestatusofthebook
537 [Link]("SELECTuserIdFROMusers")
538 result1=[Link]()
539 [Link]("SELECTbookIdFROMbooks")
540 result2=[Link]()
541 [Link]("SELECTissueStatusFROMbooksWHEREbookId=%s",(bookId,))
542 result3=[Link]()
543 [Link]()
544
545 if(userId,)inresult1:
546 if(bookId,)inresult2:
547 #Checkifthebookisnotalreadyissued
548 ifresult3[0][0]=="notissued":
549 #ExecuteSQLqueriestoupdatebookdetailsandmarkit as
550 issued
551 [Link](
552 "UPDATEbooksSETissueDate=CURRENT_DATEWHEREbookId
553 =%s",
554 (bookId,),
555 )
556 [Link](
557 "UPDATEbooksSETissueTime=CURRENT_TIMEWHEREbookId
558 =%s",
559 (bookId,),
560 )
561 [Link](
562 "UPDATEbooksSETissueStatus='issued'WHEREbookId=
563 %s",
564 (bookId,),
565 )
566 [Link](
567 "UPDATEbooksSETreturnDate=NULLWHEREbookId=%s",
568 (bookId,)
569 )
570 [Link](
571 "UPDATEbooksSETreturnTime=NULLWHEREbookId=%s",
572 (bookId,)
573 )
574 [Link](
575 "UPDATEbooksSETissuedUserId=%sWHEREbookId=%s",
576 (userId,bookId),
577 )
578 [Link]()
579 [Link](
580 "selectissuedUserId,bookName,issueDate,issueTimefrom
581 books where bookId=%s",
582 (bookId,),
583 )
584 result=[Link]()
585 [Link](
586 "INSERT INTO issuedBooksDetails (userId,
587 bookId,bookName,issueDate,issueTime)VALUES(%s,%s,%s,%s,%s)",
588 (result[0][0],bookId,result[0][1],result[0][2],
589 result[0][3]),
590 )
591 [Link]()
592
593 print(" -------------------------- ")
594 print(

29|Page
595 f'BookofBookId"{bookId}"isissuedsuccessfullyto the
596 User of User Id "{userId}".'
597 )
598 print(" --------------------------")
599 returnPolicy()
600 issueBookMenu()
601 else:
602 #Notifytheuserthatthebookisalreadyissued
603 print(
604 f'Thebookofbookid"{bookId}"isalreadyissuedby
605 anotheruser.'
606 )
607 print(" --------------------------")
608 issueBookMenu()
609 else:
610 print(
611 f"Bookwithbookid{bookId}doesnotavailableinthe digital
612 library."
613 )
614 print(" --------------------------")
615 issueBookMenu()
616 else:
617 print(f"Userwithuserid{userId}doesnotexistsinthedigital library.")
618 print(" ")
619 issueBookMenu()
620
621
622 #Functiontodisplaythereturnbookmenuandhandleuserchoices
623 defreturnBookMenu():
624 print("1. Home")
625 print("[Link]")
626 print("[Link]")
627 userChoice=int(input("EnteryourChoicetoContinue:")) print("
628 ")
629
630 #Userchoiceshandling
631 ifuserChoice==1:
632 home()
633 elifuserChoice==2:
634 admin()
635 elifuserChoice==3:
636 exiting()
637 else:
638 validOption()
639
640
641 #Functiontoreturna book
642 defreturnBook():
643 print(" ")
644 print("ReturnBook")
645 print(" ")
646 bookId=int(input("EntertheBookIDtobeReturned:"))
647
648 #ExecuteSQLquerytochecktheissuestatusofthebook
649 [Link]("SELECTbookIdFROMbooks") result1
650 = [Link]()
651 [Link]("SELECTissueStatusFROMbooksWHEREbookId=%s",(bookId,))
652 result2 = [Link]()
653
654 [Link]()
655
656 if(bookId,)inresult1:
657 #Checkifthebookisissued
658 ifresult2[0][0]=="issued":
659 #ExecuteSQLqueriestoupdatebookdetailsandmarkit as
660

30|Page
661 returned
662 [Link](
663 "UPDATEbooksSETreturnDate=CURRENT_DATEWHEREbookId=
664 %s",
665 (bookId,),
666 )
667 [Link](
668 "UPDATEbooksSETreturnTime=CURRENT_TIMEWHEREbookId=
669 %s",
670 (bookId,),
671 )
672 [Link](
673 "UPDATEbooksSETissueStatus='notissued'WHEREbookId=
674 %s",
675 (bookId,),
676 )
677 [Link]()
678 [Link](
679 "selectissuedUserId,returnDate,returnTimefrombookswhere
680 bookId=%s",
681 (bookId,),
682 )
683 result=[Link]()
684 [Link](
685 "UPDATEissuedBooksDetailsSETreturnDate=%s,returnTime
686 =%sWHEREuserId=%sANDbookId= %s",
687 (result[0][1],result[0][2],result[0][0],bookId),
688 )
689
690 [Link]()
691 [Link](
692 "UPDATEbooksSETissuedUserId=NULLWHEREbookId=%s",
693 (bookId,)
694 )
695 [Link]()
696
697 print(f'Thebookofbookid"{bookId}"isreturned successfully.')
698
699 [Link]("selectissueDatefrombooksWHEREbookId=%s",
700 (bookId,))
701 issueDate=[Link]()
702 [Link]("selectreturnDatefrombooksWHEREbookId=%s",
703 (bookId,))
704 returnDate=[Link]()
705 [Link]()
706
707 [Link]("UPDATEbooksSETissueDate=NULLWHEREbookId=
708 %s",(bookId,))
709 [Link]("UPDATEbooksSETissueTime=NULLWHEREbookId=
710 %s",(bookId,))
711 [Link]("UPDATEbooksSETreturnDate=NULLWHEREbookId=
712 %s",(bookId,))
713 [Link]("UPDATEbooksSETreturnTime=NULLWHEREbookId=
714 %s",(bookId,))
715 [Link]()
716
717 d1 = [Link](f"{issueDate[0][0]}", "%Y-%m-%d")
718 d2=[Link](f"{returnDate[0][0]}","%Y-%m-%d")
719 dateDifference = d1 - d2
720
721 [Link]>14:
722 extraDays=[Link]-14 fine =
723 extraDays * 5
724 print("Fine(inRs.):",fine) [Link](
725
726

31|Page
727 "updateissuedBooksDetailssetfineInRs=%swhere userId=%s
728 and bookId=%s",
729 (fine,result[0][0],bookId),
730 )
731 [Link]()
732 else:
733 fine=0*5
734 print("Fine(inRs.):",fine) [Link](
735 "updateissuedBooksDetailssetfineInRs=%swhere userId=%s
736 and bookId=%s",
737 (fine,result[0][0],bookId),
738 )
739 [Link]()
740
741 print(" --------------------------")
742 returnBookMenu()
743 else:
744 #Notifytheuserthatthebookisnotissued
745 print(f'Thebookofbookid"{bookId}"isnotissuedbyany
746 user.')
747 print(" --------------------------")
748 returnBookMenu()
749 else:
750 print(f"Bookwithbookid{bookId}doesnotavailableinthe digital
751 library.")
752 print(" ")
753 returnBookMenu()
754
755
756 #Functiontodisplaytheaddusermenuandhandleuserchoices
757 defaddUserMenu():
758 #Addusermenuoptions
759 print("[Link]")
760 print("[Link]")
761 print("[Link]")
762 userChoice=int(input("EnteryourChoicetoContinue:")) print("
763 ")
764
765 #Userchoiceshandling
766 ifuserChoice==1:
767 home()
768 elifuserChoice==2:
769 modifyUser()
770 elifuserChoice==3:
771 exiting()
772 else:
773 validOption()
774
775
776 #Functiontoaddanew user
777 defaddUser():
778 print(" ")
779 print("AddUser")
780 print(" ")
781 #Getuserinputforuserdetails
782 userId=int(input("EntertheUserID:")) userName
783 = input("Enter the User Name : ")
784 userPhoneNumber=input("EntertheUserPhoneNumber:")
785 userEmailId = input("Enter the User Email ID : ")
786 password = input("Enter the User Password : ")
787 print(" ")
788
789 [Link]("SELECTuserIdFROMusers") result
790 = [Link]()
791 [Link]()
792

32|Page
793
794 if(userId,)inresult: print(
795 f'Theuserofusernumber"{userId}"isalreadyenrolledinthe digital
796 library.'
797 )
798 print(" ")
799 addUserMenu()
800 else:
801 #ExecuteSQLquerytoinsertthenewuserintothedatabase
802 [Link](
803 "INSERTINTOusers(userId,userName,phoneNumber,emailId,
804 password) VALUES (%s, %s, %s, %s, %s)",
805 (userId,userName,userPhoneNumber,userEmailId,password),
806 )
807 [Link]()
808
809 #Notifytheuserthattheuserhasbeenaddedsuccessfully
810 print(" ")
811 print("User added successfully!")
812 print(" ")
813 addUserMenu()
814
815
816 #Functiontodisplaythedeleteusermenuandhandleuserchoices
817 defdeleteUserMenu():
818 #Deleteusermenuoptions
819 print("[Link]")
820 print("[Link]")
821 print("[Link]")
822 userChoice=int(input("EnteryourChoicetoContinue:")) print("
823 ")
824
825 #Userchoiceshandling
826 ifuserChoice==1:
827 home()
828 elifuserChoice==2:
829 modifyUser()
830 elifuserChoice==3:
831 exiting()
832 else:
833 validOption()
834
835
836 #Functiontodeletea user
837 defdeleteUser():
838 print(" ")
839 print("DeleteUser")
840 print(" ")
841 #GetuserinputfortheuserIDtobedeleted
842 userId=int(input("EntertheUserID:"))
843 choice=input("AreyousuretodeletetheUser?(Yes/No):")
844
845 [Link]("SELECTuserIdFROMusers") result
846 = [Link]()
847 [Link]()
848
849 [Link]()in["yes","y"]: if
850 (userId,) in result:
851 [Link]("DELETEFROMusersWHEREuserId=%s",(userId,))
852 [Link]()
853
854 #Notifytheuserthattheuserhasbeendeletedsuccessfully
855 print("Userdeletedsuccessfully!")
856 print(" --------------------------")
857 deleteUserMenu()
858

33|Page
859 else:
860 print(
861 f'Theuserofuserid"{userId}"doesnotenrolledinthe digital
862 library.'
863 )
864 print(" --------------------------")
865 deleteUserMenu()
866 elif [Link]() in ["no", "n"]:
867 print(" ")
868 print("UserNotDeleted!")
869 print(" --------------------------")
870 deleteUserMenu()
871 else:
872 validOption()
873
874
875 #Functiontodisplaytheupdateusermenuandhandleuserchoices
876 defupdateUserMenu():
877 print("1. Home")
878 print("[Link]")
879 print("[Link]")
880 userChoice=int(input("EnteryourChoicetoContinue:"))
881
882 #Userchoiceshandling
883 ifuserChoice==1:
884 home()
885 elifuserChoice==2:
886 updateUser()
887 elifuserChoice==3:
888 exiting()
889 else:
890 validOption()
891
892
893 defnotUser(userId):
894 print(f'Theuserofuserid"{userId}"doesnotenrolledinthedigital library.')
895 print(" ")
896 updateBookMenu()
897
898
899 #Functiontoupdateuserdetails
900 defupdateUser():
901 print(" ")
902 print("Update User Details")
903 print(" ")
904 # Display user update options
905 print("1. Update the User ID")
906 print("[Link]")
907 print("[Link]")
908 print("4. Update the User Email ID")
909 print("5. Update the User Password")
910 print("6. Home")
911 print("[Link]")
912 print("[Link]")
913 #Getuserchoice
914 userChoice=int(input("EnteryourChoicetoContinue:")) print("
915 ")
916
917 [Link]("SELECTuserIdFROMusers") result
918 = [Link]()
919 [Link]()
920
921 ifuserChoice==1:
922 #Updateuser ID
923 currentUserId=int(input("EntertheCurrentUserID:"))
924

34|Page
925 newUserId=int(input("EntertheNewUserID:"))
926
927 if(currentUserId,)inresult:
928 [Link](
929 "updateuserssetuserId=%swhereuserId=%s",(newUserId,
930 currentUserId)
931 )
932 [Link]()
933
934 print("UserIDchangedSuccessfully!")
935 print(" --------------------------")
936 updateUserMenu()
937 else:
938 notUser(currentUserId)
939
940 elifuserChoice==2:
941 #Updateusername
942 userId = int(input("Enter the User ID : "))
943 newUserName=input("EntertheNewUserName:")
944
945 if(userId,)inresult: [Link](
946 "updateuserssetuserName=%swhereuserId=%s", (newUserName,
947 userId)
948 )
949 [Link]()
950
951 print("UserNamechangedSuccessfully!")
952 print(" --------------------------")
953 updateUserMenu()
954 else:
955 notUser(userId)
956
957 elifuserChoice==3:
958 #Updateuserphonenumber
959 userId = int(input("Enter the Current User ID : "))
960 newPhoneNumber=input("EntertheNewPhoneNumber:")
961
962 if(userId,)inresult: [Link](
963 "updateuserssetphoneNumber=%swhereuserId=%s",
964 (newPhoneNumber, userId),
965 )
966 [Link]()
967
968 print("UserPhoneNumberchangedSuccessfully!")
969 print(" --------------------------")
970 updateUserMenu()
971 else:
972 notUser(userId)
973
974 elifuserChoice==4:
975 #Updateuseremail ID
976 userId=int(input("EntertheCurrentUserID:")) newEmailId
977 = input("Enter the New Email ID : ")
978
979 if(userId,)inresult: [Link](
980 "updateuserssetemailId=%swhereuserId=%s",(newEmailId,
981 userId)
982 )
983 [Link]()
984
985 print("UserEmailIDchangedSuccessfully!")
986 print(" --------------------------")
987 updateUserMenu()
988
989
990

35|Page
991 else:
992 notUser(userId)
993
994 elifuserChoice==5:
995 #Updateuserpassword
996 userId=int(input("EntertheCurrentUserID:")) newPassword
997 = input("Enter the New Password : ")
998 if(userId,)inresult:
999 [Link](
1000 "updateuserssetpassword=%swhereuserId=%s",
1001 (newPassword, userId)
1002 )
1003 [Link]()
1004
1005 print("UserPasswordchangedSuccessfully!")
1006 print(" --------------------------")
1007 updateUserMenu()
1008 else:
1009 notUser(userId)
1010
1011 elifuserChoice==6: #
1012 Return to home
1013 home()
1014 elifuserChoice==7:
1015 #Gobacktotheprevious menu
1016 modifyUser()
1017 elif userChoice == 8:
1018 #Exittheprogram
1019 exiting()
1020 else:
1021 validOption()
1022
1023
1024 #Functiontomodifyuser
1025 defmodifyUser():
1026 print(" ")
1027 print("ModifyUser")
1028 print(" ")
1029 #Displayusermodificationoptions
1030 print("1. Add User")
1031 print("[Link]")
1032 print("[Link]")
1033 print("4. Home")
1034 print("[Link]")
1035 print("[Link]")
1036 #Getuserchoice
1037 userChoice=int(input("EnteryourChoicetoContinue:")) print("
1038 ")
1039
1040 #Userchoiceshandling
1041 if userChoice == 1:
1042 #Addanewuser
1043 addUser()
1044 elifuserChoice==2: #
1045 Delete a user
1046 deleteUser()
1047 elifuserChoice==3:
1048 #Updateuserdetails
1049 updateUser()
1050 elifuserChoice==4: #
1051 Return to home
1052 home()
1053 elifuserChoice==5:
1054 #Returntotheprevious menu
1055 admin()
1056 elifuserChoice==6:

36|Page
1057 #Exittheprogram
1058 exiting()
1059 else:
1060 validOption()
1061
1062
1063 #Displayusersmenuoptions
1064 defdisplayUsersMenu():
1065 print("1. Home")
1066 print("[Link]")
1067 print("[Link]")
1068 userChoice=int(input("EnteryourChoicetoContinue:"))
1069
1070 #Userchoiceshandling
1071 ifuserChoice==1:
1072 home()
1073 elifuserChoice==2: admin()
1074 elifuserChoice==3:
1075 exiting()
1076 else:
1077 validOption()
1078
1079
1080 #Functiontodisplayallusers
1081 defdisplayUsers():
1082 print(" ")
1083 print("DisplayUsers")
1084 print(" --------------------------")
1085 # Fetch all users from the database
1086 [Link]("SELECT*FROMusersORDERBYuserId") result =
1087 [Link]()
1088 [Link]()
1089
1090 ifresult:
1091 #Displayuserinformation
1092 print("UsersenrolledintheDigitalLibraryare:") i = 0
1093 forrowinresult: i
1094 += 1
1095 r=length(i)
1096 print(f"{i}.UserID:{row[0]}")
1097 print(""*r+f"UserName:{row[1]}")
1098 print(""*r+f"PhoneNumber:{row[2]}")
1099 print(""*r+f"EmailID:{row[3]}")
1100 print(""*r+f"AdminStatus:{row[5]}") print("
1101 ---------------------------------")
1102 displayUsersMenu()
1103
1104 else:
1105 print("Nousersfound.")
1106 print(" --------------------------")
1107 displayUsersMenu()
1108
1109
1110 #Searchusermenuoptions
1111 defsearchUsersMenu():
1112 print("1. Home")
1113 print("[Link]")
1114 print("[Link]")
1115 userChoice=int(input("EnteryourChoicetoContinue:"))
1116
1117 #Userchoiceshandling
1118 ifuserChoice==1:
1119 home()
1120 elifuserChoice==2:
1121
1122

37|Page
1123 searchUsers()
1124 elifuserChoice==3:
1125 exiting()
1126 else:
1127 validOption()
1128
1129
1130 #Functiontosearchusersby ID
1131 defsearchUsersbyId():
1132 print(" --------------------------")
1133 print("Search Users by User ID")
1134 print(" ")
1135 #GetuserIDtosearch
1136 userId=int(input("EntertheUserIDtosearchtheUser:"))
1137
1138 #Searchfortheuserinthedatabase
1139 [Link]("SELECT*FROMusersWHEREuserId=%s",(userId,))
1140 result = [Link]()
1141 [Link]()
1142
1143 ifresult:
1144 #Displayuserinformationiffound
1145 print(f'UserenrolledintheDigitalLibrarywiththeUserID "{userId}" is
1146 :')
1147 i=0
1148 forrowinresult: i
1149 += 1
1150 r=length(i)
1151 print(f"{i}.UserID:{row[0]}")
1152 print(""*r+f"UserName:{row[1]}")
1153 print(""*r+f"PhoneNumber:{row[2]}")
1154 print(""*r+f"EmailID:{row[3]}")
1155 print(""*r+f"AdminStatus:{row[5]}") print("
1156 ---------------------------------")
1157 searchUsersMenu()
1158
1159 else:
1160 #Handlecasewhennouserisfound
1161 print(f'Nouserfoundwiththeuserid"{userId}".')
1162 print(" ")
1163 searchUsersMenu()
1164
1165
1166 #Functiontosearchusersbykeyword
1167 defsearchUsersbyKeyword():
1168 print(" ")
1169 print("Search Users by Keyword")
1170 print(" ")
1171 #Getkeywordinputfromtheuser
1172 keyword=input("EnteraKeywordtosearchUsers:")
1173
1174 #Searchforuserswiththegivenkeywordintheirnames
1175 [Link](
1176 "SELECT*FROMusersWHEREuserNameLIKE'%{}%'ORDERBY
1177 userId".format(keyword)
1178 )
1179 result=[Link]()
1180 [Link]()
1181
1182 ifresult:
1183 #Displayuserinformationifusersarefound
1184 print(
1185 f'UsersenrolledintheDigitalLibrarywiththeKeyword "{keyword}"
1186 are :'
1187 )
1188 i=0

38|Page
1189 forrowinresult: i
1190 += 1
1191 r=length(i)
1192 print(f"{i}.UserID:{row[0]}")
1193 print(""*r+f"UserName:{row[1]}")
1194 print(""*r+f"PhoneNumber:{row[2]}")
1195 print(""*r+f"EmailID:{row[3]}")
1196 print(""*r+f"AdminStatus:{row[5]}") print("
1197 ---------------------------------")
1198 searchUsersMenu()
1199
1200 else:
1201 #Handlecasewhennouserisfound
1202 print(f'Nousersfoundwiththekeyword"{keyword}".')
1203 print(" ")
1204 searchUsersMenu()
1205
1206
1207 #Functiontosearchusers
1208 defsearchUsers():
1209 print(" ")
1210 print("SearchUsers")
1211 print(" ")
1212 #Usersearchmenu
1213 print("[Link]")
1214 print("[Link]")
1215 print("3. Home")
1216 print("[Link]")
1217 print("[Link]")
1218 userChoice=int(input("EnteryourChoicetoContinue:")) print("
1219 ")
1220
1221 #Userchoiceshandling
1222 if userChoice == 1:
1223 searchUsersbyId()
1224 elif userChoice == 2:
1225 searchUsersbyKeyword()
1226 elifuserChoice==3:
1227 home()
1228 elifuserChoice==4: admin()
1229 elifuserChoice==5:
1230 exiting()
1231 else:
1232 validOption()
1233
1234
1235 #Functiontomodifybooks
1236 defmodifyBook():
1237 print(" ")
1238 print("ModifyBook")
1239 print(" ")
1240 #Bookmodificationmenu
1241 print("1. Add Book")
1242 print("2. Delete Book")
1243 print("[Link]")
1244 print("4. Home")
1245 print("[Link]")
1246 print("[Link]")
1247 userChoice=int(input("EnteryourChoicetoContinue:")) print("
1248 ")
1249
1250 #Userchoiceshandling
1251 ifuserChoice==1: addBook()
1252 elifuserChoice==2:
1253
1254

39|Page
1255 deleteBook()
1256 elifuserChoice==3:
1257 updateBook()
1258 elifuserChoice==4:
1259 home()
1260 elifuserChoice==5: admin()
1261 elifuserChoice==6:
1262 exiting()
1263 else:
1264 validOption()
1265
1266
1267 #Functiontomanagenotes
1268 defnotes():
1269 print(" ")
1270 print("Notes")
1271 print(" ")
1272 # Display menu options
1273 print("1. Modify Note")
1274 print("[Link]")
1275 print("3. Search Notes")
1276 print("4. Home")
1277 print("[Link]")
1278 print("[Link]")
1279 #Getuserchoice
1280 userChoice=int(input("EnteryourChoicetoContinue:")) print("
1281 ")
1282
1283 #Handleuserchoices
1284 ifuserChoice==1:
1285 modifyNote()
1286 elifuserChoice==2:
1287 displayNotes()
1288 elifuserChoice==3:
1289 searchNotes()
1290 elifuserChoice==4:
1291 home()
1292 elifuserChoice==5:
1293 user()
1294 elifuserChoice==6:
1295 exiting()
1296 else:
1297 validOption()
1298
1299
1300 #Functiontodisplaytheaddnotemenuandhandleuserchoices
1301 def addNoteMenu():
1302 print("[Link]")
1303 print("[Link]")
1304 print("[Link]")
1305 #Getuserchoice
1306 userChoice=int(input("EnteryourChoicetoContinue:"))
1307
1308 #Handleuserchoices
1309 ifuserChoice==1:
1310 home()
1311 elifuserChoice==2:
1312 modifyNote()
1313 elifuserChoice==3:
1314 exiting()
1315 else:
1316 validOption()
1317
1318
1319 #Functiontoadd note
1320

40|Page
1321 defaddNote():
1322 print(" ")
1323 print("AddNote")
1324 print(" ")
1325 #Getnotedetailsfromtheuser
1326 noteNumber = int(input("Enter the Note Number : "))
1327 noteTitle = input("Enter the Note Title : ")
1328 noteDescription=input("EntertheNoteDescription:")
1329 print(" ")
1330
1331 [Link]("SELECTnoteNumberFROMnoteswhereuserId=%s",(USERID,)) result =
1332 [Link]()
1333 [Link]()
1334
1335 if(noteNumber,)inresult:
1336 print(
1337 f'Thenoteofnotenumber"{noteNumber}"isalreadyexistsin the
1338 digital library.'
1339 )
1340 print(" ")
1341 addNoteMenu()
1342
1343 else:
1344 #ExecuteSQLquerytoinsertthenoteintothedatabase
1345 [Link](
1346 "INSERT INTO notes (userId, noteNumber, noteTitle,
1347 noteDescription,updateDate,updateTime)VALUES(%s,%s,%s,%s, CURRENT_DATE,
1348 CURRENT_TIME)",
1349 (USERID,noteNumber,noteTitle,noteDescription),
1350 )
1351 [Link]()
1352
1353 print(f'Thenoteofnotenumber"{noteNumber}"isadded
1354 successfully.')
1355 print(" ")
1356 addNoteMenu()
1357
1358
1359 #Functiontodisplaythedeletenotemenuandhandleuserchoices
1360 defdeleteNoteMenu():
1361 #Displaymenuoptionsafterdeletingthenote
1362 print("[Link]")
1363 print("[Link]")
1364 print("[Link]")
1365 #Getuserchoice
1366 userChoice=int(input("EnteryourChoicetoContinue:")) print("
1367 ")
1368
1369 #Handleuserchoices
1370 ifuserChoice==1:
1371 home()
1372 elifuserChoice==2:
1373 modifyNote()
1374 elifuserChoice==3:
1375 exiting()
1376 else:
1377 validOption()
1378
1379
1380 #Functiontodeletea note
1381 defdeleteNote():
1382 print(" ")
1383 print("DeleteNote")
1384 print(" ")
1385 #Getnotenumbertobedeletedfromthe user
1386 noteNumber=int(input("EntertheNoteNumbertoDeletetheNote:"))

41|Page
1387 choice=input("AreyousuretodeletetheNote?(Yes/No):") print("
1388 ")
1389
1390 [Link]("SELECTnoteNumberFROMnoteswhereuserId=%s",(USERID,)) result =
1391 [Link]()
1392 [Link]()
1393
1394 [Link]()in["yes","y"]: if
1395 (noteNumber,) in result:
1396 #ExecuteSQLquerytodeletethenotefromthedatabase
1397 [Link](
1398 "deleteFROMnotesWHEREuserId=%sandnoteNumber=%s", (USERID,
1399 noteNumber),
1400 )
1401 [Link]()
1402
1403 print(f'Thenoteofnotenumber"{noteNumber}"isdeleted successfully.')
1404 print(" --------------------------")
1405 deleteNoteMenu()
1406
1407 else:
1408 print(
1409 f'Thenoteofnotenumber"{noteNumber}"doesnotexistsin the
1410 digital library.'
1411 )
1412 print(" --------------------------")
1413 deleteNoteMenu()
1414 elif [Link]() in ["no", "n"]:
1415 print(" ")
1416 print("NoteNotDeleted!")
1417 print(" ")
1418 deleteNoteMenu()
1419 else:
1420 validOption()
1421
1422
1423 #Functiontodisplaytheupdatenotesmenuandhandleuserchoices
1424 defupdateNotesMenu():
1425 print("1. Home")
1426 print("[Link]")
1427 print("[Link]")
1428 #Getuserchoice
1429 userChoice=int(input("EnteryourChoicetoContinue:")) print("
1430 ")
1431
1432 #Handleuserchoices
1433 ifuserChoice==1:
1434 home()
1435 elifuserChoice==2:
1436 updateNotes()
1437 elifuserChoice==3:
1438 exiting()
1439 else:
1440 validOption()
1441
1442
1443 defnotNote(noteNumber):
1444 print(
1445 f'Thenoteofnotenumber"{noteNumber}"doesnotexistsinthe digital
1446 library.'
1447 )
1448 print(" ")
1449 updateNotesMenu()
1450
1451
1452

42|Page
1453 #Functiontoupdatea note
1454 defupdateNotes():
1455 print(" ")
1456 print("UpdateNotes")
1457 print(" ")
1458 #Displayupdateoptions
1459 print("1. Update the Note Number")
1460 print("2. Update the Note Title")
1461 print("[Link]")
1462 print("4. Home")
1463 print("[Link]")
1464 print("[Link]")
1465 #Getuserchoice
1466 userChoice=int(input("EnteryourChoicetoContinue:")) print("
1467 ")
1468
1469 [Link]("SELECTnoteNumberFROMnoteswhereuserId=%s",(USERID,)) result =
1470 [Link]()
1471 [Link]()
1472
1473 #Handleuserchoices
1474 ifuserChoice==1:
1475 #UpdateNoteNumber
1476 currentNoteNumber=int(input("EntertheCurrentNoteNumber:")) newNoteNumber =
1477 int(input("Enter the New Note Number : "))
1478
1479 if(currentNoteNumber,)inresult: #
1480 Update date and time
1481 [Link](
1482 "updatenotessetupdateDate=CURRENT_DATEwhereuserId=%s and
1483 noteNumber=%s",
1484 (USERID,currentNoteNumber),
1485 )
1486 [Link](
1487 "updatenotessetupdateTime=CURRENT_TIMEwhereuserId=%s and
1488 noteNumber=%s",
1489 (USERID,currentNoteNumber),
1490 )
1491 #UpdateNoteNumber
1492 [Link](
1493 "updatenotessetnoteNumber=%swhereuserId=%sand
1494 noteNumber=%s",
1495 (newNoteNumber,USERID,currentNoteNumber),
1496 )
1497 [Link]()
1498
1499 print("NoteNumberchangedSuccessfully!")
1500 print(" --------------------------")
1501 updateNotesMenu()
1502 else:
1503 notNote(currentNoteNumber)
1504
1505 elifuserChoice==2:
1506 #UpdateNoteTitle
1507 noteNumber=int(input("EntertheCurrentNoteNumber:")) newTitle
1508 = input("Enter the New Note Title : ")
1509
1510 if(noteNumber,)inresult: #
1511 Update date and time
1512 [Link](
1513 "updatenotessetupdateDate=CURRENT_DATEwhereuserId=%s and
1514 noteNumber=%s",
1515 (USERID,noteNumber),
1516 )
1517 [Link](
1518 "updatenotessetupdateTime=CURRENT_TIMEwhereuserId=%s

43|Page
1519 andnoteNumber=%s",
1520 (USERID,noteNumber),
1521 )
1522 #UpdateNoteTitle
1523 [Link](
1524 "updatenotessetnoteTitle=%swhereuserId=%sand
1525 noteNumber=%s",
1526 (newTitle,USERID,noteNumber),
1527 )
1528 [Link]()
1529
1530 print("NoteTitlechangedSuccessfully!")
1531 print(" --------------------------")
1532 updateNotesMenu()
1533 else:
1534 notNote(noteNumber)
1535
1536 elifuserChoice==3:
1537 #UpdateNoteDescription
1538 noteNumber=int(input("EntertheCurrentNoteNumber:"))
1539 newDescription=input("EntertheNewNoteDescription:")
1540
1541 if(noteNumber,)inresult: #
1542 Update date and time
1543 [Link](
1544 "updatenotessetupdateDate=CURRENT_DATEwhereuserId=%s and
1545 noteNumber=%s",
1546 (USERID,noteNumber),
1547 )
1548 [Link](
1549 "updatenotessetupdateTime=CURRENT_TIMEwhereuserId=%s and
1550 noteNumber=%s",
1551 (USERID,noteNumber),
1552 )
1553 #UpdateNoteDescription
1554 [Link](
1555 "updatenotessetnoteDescription=%swhereuserId=%sand
1556 noteNumber=%s",
1557 (newDescription,USERID,noteNumber),
1558 )
1559 [Link]()
1560
1561 print("NoteDescriptionchangedsuccessfully!")
1562 print(" --------------------------")
1563 updateNotesMenu()
1564 else:
1565 notNote(noteNumber)
1566
1567 elifuserChoice==5:
1568 home()
1569 elifuserChoice==6:
1570 modifyNote()
1571 elifuserChoice==7:
1572 exiting()
1573 else:
1574 validOption()
1575
1576
1577 #Functiontohandlenotemodifications
1578 defmodifyNote():
1579 print(" ")
1580 print("ModifyNotes")
1581 print(" ")
1582 #Displaymodificationoptions
1583 print("1. Add Note")
1584 print("[Link]")

44|Page
1585 print("[Link]")
1586 print("4. Home")
1587 print("[Link]")
1588 print("[Link]")
1589 #Getuserchoice
1590 userChoice=int(input("EnteryourChoicetoContinue:")) print("
1591 ")
1592
1593 #Handleuserchoices
1594 ifuserChoice==1: addNote()
1595 elifuserChoice==2:
1596 deleteNote()
1597 elifuserChoice==3:
1598 updateNotes()
1599 elifuserChoice==4:
1600 home()
1601 elifuserChoice==5: admin()
1602 elifuserChoice==6:
1603 exiting()
1604 else:
1605 validOption()
1606
1607
1608 #Functiontodisplaythedisplaynotesmenuandhandleuserchoices
1609 defdisplayNotesMenu():
1610 print("1. Home")
1611 print("[Link]")
1612 print("[Link]")
1613 userChoice=int(input("EnteryourChoicetoContinue:")) print("
1614 ")
1615
1616 #Handleuserchoices
1617 ifuserChoice==1:
1618 home()
1619 elifuserChoice==2:
1620 user()
1621 elifuserChoice==3:
1622 exiting()
1623 else:
1624 validOption()
1625
1626
1627 #Functiontodisplaynotes
1628 defdisplayNotes():
1629 # Fetch all notes from the database
1630 [Link]("SELECT*FROMnotesORDERBYnoteNumber")
1631 result = [Link]()
1632 [Link]()
1633
1634 #Checkiftherearenotesavailable
1635 ifresult:
1636 print(f"NotesavailableintheDigitalLibraryare:") i = 0
1637 forrowinresult: i
1638 += 1
1639 r=length(i)
1640 print(f"{i}.NoteNumber:{row[1]}")
1641 print(""* r + f"Note Title : {row[2]}")
1642 print(""*r+f"NoteDescription:{row[3]}")
1643 print(""* r + f"Update Date : {row[4]}")
1644 print(""*r+f"UpdateTime:{row[5]}") print("
1645 ---------------------------------")
1646 displayNotesMenu()
1647
1648
1649
1650

45|Page
1651 else:
1652 #Ifnonotesare found
1653 print("Nonotesfound.")
1654 print(" --------------------------")
1655 displayNotesMenu()
1656
1657
1658 #Functiontodisplaythesearchnotesmenuandhandleuserchoices
1659 defsearchNotesMenu():
1660 print("1. Home")
1661 print("[Link]")
1662 print("[Link]")
1663 userChoice=int(input("EnteryourChoicetoContinue:"))
1664
1665 #Handleuserchoices
1666 ifuserChoice==1:
1667 home()
1668 elifuserChoice==2:
1669 searchNotes()
1670 elifuserChoice==3:
1671 exiting()
1672 else:
1673 validOption()
1674
1675
1676 #Functiontosearchnotesbynotenumber
1677 defsearchNotesbynoteNumber():
1678 #Getthenotenumbertosearch
1679 noteNumber=int(input("EntertheNoteNumbertosearchtheNote:"))
1680
1681 # Execute SQL query to fetch notes with the given note number
1682 [Link]("SELECT*FROMnotesWHEREbookId=%s",(noteNumber,)) result
1683 = [Link]()
1684 [Link]()
1685
1686 #Checkifnotesarefound
1687 ifresult:
1688 print(
1689 f'NoteavailableintheDigitalLibrarywiththeNoteNumber "{noteNumber}" is
1690 :'
1691 )
1692 i=0
1693 forrowinresult: i
1694 += 1
1695 r=length(i)
1696 print(f"{i}.NoteNumber:{row[1]}")
1697 print(""* r + f"Note Title : {row[2]}")
1698 print(""*r+f"NoteDescription:{row[3]}") print("
1699 ---------------------------------")
1700 searchNotesMenu()
1701
1702 else:
1703 # If no notes are found with the given note number
1704 print(f'Nonotefoundwiththenotenumber"{noteNumber}".')
1705 print(" ")
1706 searchNotesMenu()
1707
1708
1709 #Functiontosearchnotesbykeyword
1710 defsearchNotesbyKeyword():
1711 print(" ")
1712 print("Search Notes by Keyword")
1713 print(" ")
1714 #Getkeywordfrom user
1715 keyword=input("EnteraKeywordtosearchNotes:")
1716

46|Page
1717 #ExecuteSQLquerytofetchnoteswiththegivenkeywordinthetitle
1718 [Link](
1719 "SELECT*FROMnotesWHEREnoteTitleLIKE'%{}%'ORDERBY
1720 noteNumber".format(
1721 keyword
1722 )
1723 )
1724 result=[Link]()
1725 [Link]()
1726
1727 #Checkifnotesarefound
1728 ifresult:
1729 print(
1730 f'NotesavailableintheDigitalLibrarywiththeKeyword "{keyword}"
1731 are :'
1732 )
1733 i=0
1734 forrowinresult: i
1735 += 1
1736 r=length(i)
1737 print(f"{i}.NoteNumber:{row[1]}")
1738 print(""* r + f"Note Title : {row[2]}")
1739 print(""*r+f"NoteDescription:{row[3]}") print("
1740 ---------------------------------")
1741 searchNotesMenu()
1742
1743 else:
1744 # If no notes are found with the given keyword
1745 print(f'Nonotesfoundwiththekeyword"{keyword}".')
1746 print(" ")
1747 searchNotesMenu()
1748
1749
1750 #Functiontohandlenotesearching
1751 defsearchNotes():
1752 print(" ")
1753 print("SearchNotes")
1754 print(" ")
1755 # Display search options
1756 print("[Link]")
1757 print("2. Search by Keyword")
1758 print("3. Home")
1759 print("[Link]")
1760 print("[Link]")
1761 #Getuserchoice
1762 userChoice=int(input("EnteryourChoicetoContinue:")) print("
1763 ")
1764
1765 #Handleuserchoices
1766 if userChoice == 1:
1767 searchNotesbynoteNumber()
1768 elif userChoice == 2:
1769 searchNotesbyKeyword()
1770 elifuserChoice==3: notes()
1771 elifuserChoice==4:
1772 modifyNote()
1773 elifuserChoice==5:
1774 exiting()
1775 else:
1776 validOption()
1777
1778
1779 #Functiontodisplaythechangeadminmenuandhandleuserchoices
1780 defchangeAdminMenu():
1781 print("1. Home")
1782

47|Page
1783 print("[Link]")
1784 print("[Link]")
1785 userChoice=int(input("EnteryourChoicetoContinue:")) print("
1786 ")
1787
1788 #Handleuserchoices
1789 ifuserChoice==1:
1790 home()
1791 elifuserChoice==2: admin()
1792 elifuserChoice==3:
1793 exiting()
1794 else:
1795 validOption()
1796
1797
1798 #Functiontochangetheadminstatus
1799 defchangeAdmin():
1800 print(" ")
1801 print("ChangeAdmin")
1802 print(" ")
1803 #Getnewadmin'sIDandpasswordfromthe user
1804 newAdminId = int(input("Enter the New Admin's User ID : "))
1805 newAdminPassword = input("Enter the New Admin's Password : ")
1806 choice=input("AreyousuretochangetheAdmin?(Yes/No):") print(" ")
1807
1808 #CheckiftheentereduserIDexists
1809 [Link]("SELECTpasswordFROMusersWHEREuserId=%s",(newAdminId,)) result
1810 = [Link]()
1811 [Link]()
1812
1813 #Checktheuser'schoicetoproceedorcancel
1814 [Link]()in["yes","y"]:
1815 #IftheuserIDisnotvalid,printanerrormessage
1816 iflen(result)==0:
1817 print("Pleaseenteravaliduserid!") else:
1818 #Iftheenteredpasswordmatchestheuser'spassword
1819 ifnewAdminPassword==result[0][0]:
1820 #Updateadminstatusforallusers
1821 [Link](
1822 "UPDATEusersSETadminStatus='notadmin'WHERE adminStatus
1823 ='admin'"
1824 )
1825 [Link](
1826 "UPDATEusersSETadminStatus='admin'WHEREuserId
1827 =%s",
1828 (newAdminId,),
1829 )
1830 [Link]()
1831
1832 print("AdminChangedSuccessfully!")
1833 print(" --------------------------")
1834 changeAdminMenu()
1835
1836 else:
1837 print("Pleaseenteravalidpassword!") elif
1838 [Link]() in ["no", "n"]:
1839 print("AdminNotChanged!")
1840 print(" ")
1841 changeAdminMenu()
1842 else:
1843 validOption()
1844
1845
1846
1847
1848

48|Page
1849 #Functiontoauthenticateadmin
1850 defauthAdmin():
1851 print(" ")
1852 print("Admin Authentication")
1853 print(" ")
1854 adminId = int(input("Enter the Admin's User ID : "))
1855 adminPassword=input("EntertheAdmin'sUserPassword:")
1856
1857 #CheckiftheenteredadminIDexists
1858 [Link]("SELECTpasswordFROMusersWHEREuserId=%s",(adminId,)) result =
1859 [Link]()
1860 [Link]()
1861
1862 #IftheenteredadminIDisnotvalid,printanerrormessage
1863 iflen(result)==0:
1864 print(" ")
1865 print("Pleaseenteravaliduserid!")
1866 print(" ")
1867 else:
1868 #Iftheenteredpasswordmatchestheadmin'spassword
1869 ifadminPassword==result[0][0]:
1870 global USERID
1871 USERID=adminId
1872 print("\033[0;35m --------------------------\033[0;0m")
1873 print("\033[0;36mAdminisverifiedsuccessfully.\033[0;0m")
1874 print("\033[0;35m --------------------------\033[0;0m")
1875 admin()#Calltheadmin menu
1876 else:
1877 print("Pleaseenteravalidpassword!")
1878 print(" --------------------------")
1879
1880
1881 #Functiontodisplaytheadminmenu
1882 defadmin():
1883 print(" ")
1884 print("Admin")
1885 print(" ")
1886 print("[Link]")
1887 print("[Link] User")
1888 print("[Link]")
1889 print("[Link] Users")
1890 print("[Link] Book")
1891 print("[Link] Book")
1892 print("[Link] Book")
1893 print("[Link] Admin")
1894 print("[Link]")
1895 print("[Link]")
1896 print("[Link]")
1897 userChoice=int(input("EnteryourChoicetoContinue:")) print("
1898 ")
1899
1900 #Handleuserchoices
1901 ifuserChoice==1:
1902 print("Youaresuccessfullyloginintouserpanel.")
1903 print(" ")
1904
1905 user()
1906 elifuserChoice==2:
1907 modifyUser()
1908 elifuserChoice==3:
1909 displayUsers()
1910 elifuserChoice==4:
1911 searchUsers()
1912 elifuserChoice==5:
1913 modifyBook()
1914 elifuserChoice==6:

49|Page
1915 issueBook()
1916 elifuserChoice==7:
1917 returnBook()
1918 elifuserChoice==8:
1919 changeAdmin()
1920 elifuserChoice==9:
1921 home()
1922 elifuserChoice==10:
1923 authAdmin()
1924 elifuserChoice==11:
1925 exiting()
1926 else:
1927 validOption()
1928
1929
1930 #Functiontoauthenticateauser
1931 defauthUser():
1932 print(" ")
1933 print("User Authentication")
1934 print(" ")
1935 userId = int(input("Enter the User ID : "))
1936 password=input("EntertheUserPassword:")
1937
1938 #CheckiftheentereduserIDexists
1939 [Link]("SELECTpasswordFROMusersWHEREuserId=%s",(userId,)) result =
1940 [Link]()
1941 [Link]()
1942
1943 #IftheentereduserIDisnotvalid,printanerrormessage
1944 iflen(result)==0:
1945 print(" ")
1946 print("Pleaseenteravaliduserid!")
1947 print(" ")
1948 else:
1949 #Iftheenteredpasswordmatchestheuser'spassword
1950 ifpassword==result[0][0]:
1951 global USERID
1952 USERID=userId
1953 print("\033[0;35m --------------------------\033[0;0m")
1954 print("\033[0;36mUserisverifiedsuccessfully.\033[0;0m")
1955 print("\033[0;35m --------------------------\033[0;0m")
1956 user()#Calltheusermenu
1957 else:
1958 print("PleaseEnteraValidPassword!")
1959 print(" --------------------------")
1960
1961
1962 #Functiontosearch&displaythewikipediaarticles
1963 defwikipediaArticles():
1964 #Functiontofetcharticledetails
1965 deffetchingArticle(keyword,articleLength=1500):
1966 #CreatingaWikipediaAPIobject
1967 wiki=[Link](language="en",user_agent="digital-
1968 library/1.1")
1969 #Fetchingthepageforthegivensearchquery
1970 page=[Link](keyword)
1971
1972 #Checkingifthepageexists
1973 [Link]():
1974 print(
1975 f'Sorry,theWikipediaArticleforthekeyword"{keyword}" does
1976 not exists.'
1977 )
1978 print(" --------------------------")
1979 else:
1980 #Displayingarticletitle

50|Page
1981 print("Title:")
1982 print([Link])
1983 print("URL:")
1984 print([Link])
1985 #Displayingasummaryofthearticlewithinthespecified
1986 length
1987 print("Summary:")
1988
1989 start=0
1990 end=157
1991 article=[Link][:articleLength]
1992
1993 whileend<=articleLength:
1994 print(article[start:end])
1995 start+=157
1996 end+=157
1997 else:
1998 print(" -------------------------- ")
1999
2000 print(" ")
2001 print("SearchArticles")
2002 print(" -------------------------- ")
2003 #Takinguserinputforthekeywordandarticlelength
2004 keyword=input("EntertheKeywordforsearchingtheWikipediaArticle
2005 : ")
2006 articleLength=int(input("EntertheArticleLength:"))
2007 print(" ")
2008
2009 #Callingthefunctiontofetchanddisplaythearticle
2010 fetchingArticle(keyword,articleLength)
2011
2012 userMenu()
2013
2014
2015 #Functiontosearch&displaythenews
2016 defnews():
2017 deffetchNews(apiKey,country="in",category="science",numArticles=5): url
2018 = f"[Link]
2019 params={
2020 "apiKey": apiKey,
2021 "country": country,
2022 "category": category,
2023 "pageSize":numArticles,
2024 }
2025 response=[Link](url,params=params)
2026
2027 ifresponse.status_code==200:
2028 news_data=[Link]()
2029 articles=news_data.get("articles",[])
2030
2031 fori,articleinenumerate(articles,start=1):
2032 print(f"{i}.{article['title']}")
2033 print(f" Source:{article['source']['name']}")
2034 print(f" URL:{article['url']}")
2035 print(" -------------------------- ")
2036
2037 else:
2038 print(f"Error{response.status_code}:{[Link]}")
2039 print(" -------------------------- ")
2040
2041 API_KEY="YOUR_API_KEY"
2042
2043 print(" ")
2044 print("News")
2045 print(" ")
2046 print("Countrycodesare:")

51|Page
2047 print("[Link]
2048 print("Categories are : ")
2049 print("business,entertainment,general,health,science,sports,
2050 technology")
2051 print(" ")
2052 country=input("EntertheCountryCode:") category =
2053 input("Enter the Category : ")
2054 numArticles=int(input("EntertheNumberofArticles:")) print("
2055 ")
2056
2057 fetchNews(API_KEY,country,category,numArticles) userMenu()
2058
2059
2060 #Functiontodisplaytheissuedbooksdetailsofauser
2061 defissuedBooksDetails():
2062 print(" ")
2063 print("Issued Books Details")
2064 print(" ")
2065 returnPolicy()
2066
2067 [Link](
2068 "SELECT*FROMissuedBooksDetailsWHEREuserId=%sORDERBYbookId", (USERID,)
2069 )
2070 result=[Link]()
2071 [Link]()
2072
2073 ifresult==[]:
2074 print("NoBooksIssued!")
2075 print(" --------------------------")
2076 userMenu()
2077
2078 else:
2079 i=0
2080 forrowinresult: i
2081 += 1
2082 r=length(i)
2083 print(f"{i}.BookID:",row[1])
2084 print(""*r+"BookName:",row[2])
2085 print(""*r+"IssueDate:",row[3])
2086 print(""*r+"IssueTime:",row[4])
2087 print(""*r+"ReturnDate:",row[5])
2088 print(""*r+"ReturnTime:",row[6])
2089 print(""*r+"Fine(inRs.):",row[7]) print("
2090 ---------------------------------")
2091 userMenu()
2092
2093
2094 #Functiontodisplaytheusermenu
2095 defuser():
2096 print(" ")
2097 print("User")
2098 print(" ")
2099 #CheckiftheentereduserIDexists
2100 [Link]('SELECTuserIdFROMusersWHEREadminStatus="admin"')
2101 result = [Link]()
2102 [Link]()
2103
2104 ifresult[0][0]==USERID:
2105 print("[Link]")
2106 print("[Link] the Library")
2107 print("[Link]")
2108 print("[Link]")
2109 print("[Link] Books")
2110
2111
2112

52|Page
2113 print("[Link] Books")
2114 print("[Link]")
2115 print("[Link]")
2116 print("[Link]")
2117 print("[Link]")
2118 print("[Link]")
2119 userChoice=int(input("EnteryourChoicetoContinue:")) print("
2120 ")
2121
2122 #Handleuserchoices
2123 ifuserChoice==1:
2124 print("Youaresuccessfullyloginintoadminpanel.")
2125 print(" --------------------------")
2126
2127 admin()
2128 elifuserChoice==2: aboutLibrary()
2129 elifuserChoice==3: news()
2130 elif userChoice == 4:
2131 wikipediaArticles()
2132 elifuserChoice==5: displayBooks()
2133 elifuserChoice==6: searchBooks()
2134 elif userChoice == 7:
2135 issuedBooksDetails()
2136 elifuserChoice==8: notes()
2137 elifuserChoice==9: home()
2138 elifuserChoice==10:
2139 authUser()
2140 elifuserChoice==11:
2141 exiting()
2142 else:
2143 validOption()
2144 else:
2145 print("[Link]")
2146 print("[Link]")
2147 print("[Link] Articles")
2148 print("[Link] Books")
2149 print("[Link] Books")
2150 print("[Link]")
2151 print("[Link]")
2152 print("[Link]")
2153 print("[Link]")
2154 print("[Link]")
2155 userChoice=int(input("EnteryourChoicetoContinue:")) print("
2156 ")
2157
2158 #Handleuserchoices
2159 ifuserChoice==1:
2160 aboutLibrary()
2161 elifuserChoice==2: news()
2162 elif userChoice == 3:
2163 wikipediaArticles()
2164 elifuserChoice==4: displayBooks()
2165 elifuserChoice==5: searchBooks()
2166 elif userChoice == 6:
2167 issuedBooksDetails()
2168 elifuserChoice==7: notes()
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178

53|Page
2179 elifuserChoice==8:
2180 home()
2181 elifuserChoice==9:
2182 authUser()
2183 elifuserChoice==10:
2184 exiting()
2185 else:
2186 validOption()
2187
2188
2189 #Functiontodisplaythemainmenu
2190 defhome():
2191 whileTrue:
2192 print("==========================")
2193 print("\033[1;32m~~~~~~~~~~~~~~~~~~~~~~~~~~\033[0;0m")
2194 print(
2195 "\033[1;31m"
2196 +pyfiglet.figlet_format("Welcometothe",font="banner3",
2197 width=1000)
2198 )
2199 print(
2200 pyfiglet.figlet_format("DigitalLibrary",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("[Link]")
2210 print("[Link]")
2211 print("[Link]")
2212 userChoice=int(input("EnteryourChoicetoContinue:")) print("
2213 ")
2214
2215 #Handleuserchoices
2216 ifuserChoice==1:
2217 authAdmin()
2218 elifuserChoice==2:
2219 authUser()
2220 elifuserChoice==3:
2221 exiting()
2222 else:
2223 validOption()
2224
2225
2226 #Callthemainmenufunction
2227 home()
2228
2229

54|Page
MY SQL
DATABASE

55|Page
Library Database:

Books Table:

Users Table:

56|Page
Notes Table:

Issued Books Details Table:

57|Page
OUTPUTS

58|Page
Starting of the program:

Admin Authentication:

Adding a new user:

59|Page
Updating user details:

Adding a new book:

60|Page
Updating book details:

61|Page
User Authentication:

About Library:

62|Page
News:

Wikipedia Articles:

63|Page
Issued Books Details:

64|Page
Exiting the program:

65|Page
System Requirements

Hardware Requirements

 Processor: Minimum Intel i3 or equivalent;


recommended Intel i5/i7 for faster execution.
 RAM: At least 4 GB; recommended 8 GB or higher for
handling larger databases.
 Storage: 500 MB free disk space for project files and
MySQL database; recommended 1 GB or more for
scalability.
 Display: Standard monitor with resolution 1024×768 or
higher for clear visualization of outputs.
 Input Devices: Keyboard and mouse for user interaction.
 Optional Devices: Printer for generating hard copies of
reports.

66|Page
Software Requirements
 Operating System: Windows 10/11, Linux (Ubuntu), or
macOS.
 Programming Language: Python (latest stable version,
e.g., 3.10+).
 Database: MySQL Community Server.
 Libraries/Modules:
o [Link] for database connectivity
o datetime for handling issue/return dates
o pyfiglet for text-based interface styling
o requests and wikipediaapi for optional external data
integration
 IDE/Editor: PyCharm, VS Code, or IDLE for Python
development.
 Additional Tools: MySQL Workbench for database
design and management.

67|Page
Future Scope
1. Cloud Integration:
o Hosting the library database on cloud platforms
(AWS, Azure, Google Cloud) for remote access.
o Enables multiple branches of a school or
institution to share a centralized system.
2. Mobile Application Development:
o Creating Android/iOS apps for students and
librarians to access the system on-the-go.
o Features like book search, issue requests, and
notifications for due dates.
3. Advanced Search and Recommendation System:
o Implementing AI-based recommendation engines
to suggest books based on user history.
o Natural Language Processing (NLP) for smarter
keyword searches.
4. Barcode/QR Code Integration:
o Automating book issue/return using barcode
scanners or QR codes.
68|Page
o Reduces manual entry errors and speeds up
transactions.
5. Enhanced Security:
o Role-based access control with encrypted
passwords.
o Audit logs to track all user and admin activities.
6. Analytics Dashboard:

 Graphical reports on most issued books, user activity, and


fine collection.
 Helps management in decision-making and resource
allocation.

69|Page
Conclusion
The Library Management System project successfully
Demonstrates how python and MYSQL can be intergrated
to automate routine library operations
o It simplifies tasks such as adding books, managing
users, issuing and returning books, and calculating
fines.
o The project ensures data accuracy, security, and
efficiency, reducing manual workload for librarians.
o By providing a user-friendly interface and
structured database management, it enhances the
overall experience for both administrators and
students.
o Though currently limited to basic functionalities, the
system lays a strong foundation for future
enhancements like cloud integration, mobile apps,
and AI-driven recommendations.
. In conclusion, this project not only fulfills academic
requirements but also provides a practical solution that
can be deployed in real-world institutions to modernize
their library operations.

70|Page
Bibliography
•Python Documentation – [Link]
•MySQL Documentation – [Link]
•Wikipedia API Documentation –
[Link]
•CBSE Informatics Practices Guidelines – Central
Board of Secondary Education, New Delhi
•Reference Books:
o“Python Programming for Beginners” by John Zelle
o“Learning MySQL” by Seyed M.M. Tahaghoghi &
Hugh Williams
•Online Resources:
•TutorialsPoint (Python & MySQL tutorials)
•GeeksforGeeks (Python-MySQL integration examples)
•W3Schools (Python and SQL basics)
.

71|Page

You might also like