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

Anant .Page

The document is a practical file for a Computer Science project on a Library Management System (Digital Library) submitted by Anant Kumar Gupta. It includes a certificate of completion, acknowledgments, required hardware and software, an introduction to the project, and detailed Python source code. The system allows user enrollment, book management, and provides a user-friendly interface for accessing library resources.

Uploaded by

puneet tiwari
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)
14 views59 pages

Anant .Page

The document is a practical file for a Computer Science project on a Library Management System (Digital Library) submitted by Anant Kumar Gupta. It includes a certificate of completion, acknowledgments, required hardware and software, an introduction to the project, and detailed Python source code. The system allows user enrollment, book management, and provides a user-friendly interface for accessing library resources.

Uploaded by

puneet tiwari
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/ 59

TAKSILAPUBLICSCHOOL

COMPUTER SCIENCE
PRACTICAL FILE
2024-25

Submitted by:
Name: ANANT KUMAR GUPTA
Class: XII-B
CBSE Roll Number:
Under the Guidance of:
MR.PUNEET TIWARI, PGT(CS)
CERTIFICATE

ThisistocertifythatVANSH VATSofclass:XII -B of
KENDRIYAVIDYALAYABERHAMPURhasdonehisprojecton
LIBRARY MANAGEMENT SYSTEM (DIGITAL LIBRARY)
undermysupervision.Hehastakeninterestandhasshown at
most sincerity in completion of this project.
Icertifythisprojectuptomyexpectation&asperguidelines
issued by CBSE, NEW DELHI.

InternalExaminer ExternalExaminer

Principal

1|Page
ACKNOWLEDGMENT

ItiswithpleasurethatIacknowledgemysinceregratitudeto our
teacher, MR. PUNEET TIWARI, PGT (CS) who taught and
undertook the responsibility of teaching the subject
computer science. I have been greatly benefited from his
classes.
Iamespeciallyindebtedtoour VicePrincipalMRS.SHwho has
always been asourceof encouragement and support
andwithoutwhoseinspirationthisprojectwouldnothave been
a successful I would like to place on record heartfelt thanks
to him.
Finally,Iwouldliketoexpressmysincereappreciationforall the
other students for my batch their friendship & the fine time
that we all shared together.

2|Page
HARDWARESANDSOFTWARESR
EQUIRED

HARDWARES
1. DesktopComputer/Laptop
2. MobilePhone

SOFTWARES
1. Python(LatestVersion)
2. MySQL
3. MySQL-Connector-Python,Requests,Wikipedia-API,
Datetime, Pyfiglet Modules

3|Page
TABLEOFCONTENTS

S.No. Topic PageNo.


1 Certificate 1
2 Acknowledgement 2
HardwaresandSoftwares
3 3
Required
4 Introduction 5
5 PythonSourceCode 10
6 MySQLDatabase 45
7 Outputs 48
8 References 56

4|Page
INTRODUCTION
TheprojectLIBRARYMANAGEMENTSYSTEM(DIGITAL
LIBRARY) includes enrolment of users, adding of books into
thelibrarysystem.Thesoftwarehasthefacilitytosearchfor
news,Wikipediaarticles.Itincludesanauthenticationfacility 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
LibraryManagementSystemcanbeloginusingauserIDand
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
protectedforpersonaluseandmakesthedataprocessing very
fast.
Thepurposeoftheprojectentitledas“DIGITALLIBRARY”is to
computerize the Front Library Management to develop
software which is user friendly, simple, fast, and cost-
effective.Italsohasanotesfacilitywheretheusercanadd notes
at any point of the program into the database.

5|Page
LIBRARY
Alibraryisacollectionofbooks,andpossiblyothermaterials and
media, that is accessible for use by its members and
members of allied institutions. Libraries provide physical or
digital materials, and may be a physical location, a virtual
space, or both. A library's collection normally includes
printed materials which may be borrowed, and usually also
includes a reference section of publications which may only
be utilized inside the premises.
Libraries can vary widely in size and may be organised and
maintained by a public body such as a government, an
institution (such as a school or museum), a corporation, or a
privateindividual.Inadditiontoprovidingmaterials,libraries
also provide the services of librarians who are trained
experts in finding, selecting, circulating and organising
information while interpreting information needs and
navigatingandanalysinglargeamountsofinformationwitha
variety of resources.

6|Page
LIBRARYMANAGEMENTSYSTEM(
DIGITAL LIBRARY)
Librarymanagementsystem(LMS),isanenterpriseresource
planning system for a library, used to track enrolled users,
availablebooks,booksissuedandtowhom,booksreturned
and it’s fines, etc.
The purpose of a librarymanagement system isto operate a
librarywithefficiencyandatreducedcosts.Thesystembeing
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
intensiveandanimmenseamountofpaperworkisinvolved. The
system saves time for both the user and the librarian.
Withjustaclicktheusercansearchforthebooksavailablein the
library. The librarian can answer queries with ease regarding
the availability of books. Adding, removing or
editingthedatabaseisasimpleprocess.Addingnewusersor
cancelling existing userships can be done with ease.
Theautomatedsystemsavesaconsiderableamountoftime as
opposed to the manual system.

7|Page
FUNCTIONSLIST

 Admin
 LoginintoUserPanel
 ModifyUser
 AddUser
 DeleteUser
 UpdateUser
 DisplayUsers
 SearchUsers
 ModifyBook
 AddBook
 DeleteBook
 UpdateBook
 IssueBook
 ReturnBook
 ChangeAdmin
 Home
 Back
 Exit
 User
 AboutLibrary

8|Page
 News
 WikipediaArticles
 DisplayBooks
 SearchBooks
 IssuedBooksDetails
 Notes
 ModifyNotes
o AddNotes
o DeleteNotes
o UpdateNotes
 DisplayNotes
 SearchNotes
 Home
 Back
 Exit

9|Page
PythonSource
Code

10|Page
1 #Importingnecessarylibraries
2 importmysql.connector
3 importpyfiglet
4 importrequests
5 importwikipediaapi
6 fromdatetimeimportdatetime
7
8
9 #ConnecttotheMySQLdatabase
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 #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 toastring
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("1.AddNote")
59 print("2.Home")
60 print("3.Back")
61 print("4.Exit")
62 #Takinguserchoiceasinput
63 userChoice=int(input("EnteryourChoicetoContinue:"))
64 print(" ")
65
66 #Handleuserchoices

11|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 c.execute("SELECTuserNameFROMusersWHEREadminStatus='admin'") userName
83 = c.fetchall()
84
85 #Retrievethetotalnumberofbooksandusersinthelibrary
86 c.execute("SELECT*FROMbooks")
87 totalBooks = c.fetchall()
88
89 c.execute("SELECT*FROMusers")
90 totalUsers = c.fetchall()
91 db.commit()
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 c.execute("SELECT*FROMbooksORDERBYbookId") result
113 = c.fetchall()
114 db.commit()
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]}")
129 print("--------------------------")
130 userMenu()
131 else:
132

12|Page
133 #Notifytheuserifnobooksarefound
134 print("Nobooksfound.")
135 print("--------------------------")
136 userMenu()
137
138
139 #Searchbooksmenuoptions
140 def searchBooksMenu():
141 print("1.AddNote")
142 print("2. Home")
143 print("3.Back")
144 print("4.Exit")
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 #FunctiontosearchbooksbyBookID
161 defsearchBooksbyId():
162 print(" ")
163 print("Search Books by Book ID")
164 print(" "
165 )
166 #GetuserinputforBookID
167 bookId=int(input("EntertheBookIDtosearchtheBook:")) print(" ")
168
169 #ExecuteSQLquerytoretrievebookinformationbyBookID
170 c.execute("SELECT*FROMbooksWHEREbookId=%s",(bookId,))
171 result = c.fetchall()
172 db.commit()
173
174 #Displaysearchresultsifbooksarefound,otherwisenotifytheuser
175 ifresult:
176 print(f'BookavailableintheDigitalLibrarywiththeBookID "{bookId}"
177 is :')
178 print(" ")
179 i=0
180 forrowinresult: i
181 += 1
182 r=length(i)
183 print(f"{i}.BookID:{row[0]}")
184 print(""* r + f"Book Name : {row[1]}")
185 print(""*r+f"PublicationYear:{row[2]}")
186 print(""* r + f"Author Name : {row[7]}")
187 print(""*r+f"IssueStatus:{row[8]}")
188 print("--------------------------")
189 searchBooksMenu()
190 else:
191 print(f'Nobookfoundwiththebookid"{bookId}".')
192 print(" ")
193 searchBooksMenu()
194
195
196 #Functiontosearchbooksbykeyword
197 defsearchBooksbyKeyword():
198 print(" ")

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

15|Page
265 #Functiontodisplaytheaddbookmenuandhandleuserchoices
266 defaddBookMenu():
267 #Addbookmenuoptions
268 print("1.Home")
269 print("2.Back")
270 print("3.Exit")
271 userChoice=int(input("EnteryourChoicetoContinue:"))
272 print(" ")
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:"))
292 bookName = input("Enter the Book Name : ")
293 publicationYear=int(input("EntertheBookPublicationYear:")) author =
294 input("Enter the Book Author Name : ")
295 print(" ")
296
297 c.execute("SELECTbookIdFROMbooks")
298 result = c.fetchall()
299 db.commit()
300
301 if(bookId,)inresult: print(
302 f'Thebookofbookid"{bookId}"isalreadyavailableinthe digital
303 library.'
304 )
305 print(" ")
306 addBookMenu()
307 else:
308 #ExecuteSQLquerytoinsertthenewbookintothedatabase
309 c.execute(
310 "INSERTINTObooks(bookId,bookName,publicationYear,author)
311 VALUES (%s, %s, %s, %s)",
312 (bookId,bookName,publicationYear,author),
313 )
314 db.commit()
315
316 #Notifytheuserthatthebookhasbeenaddedsuccessfully
317 print("Book added Successfully!")
318 print(" "
319 )
320 addBookMenu()
321
322
323 #Functiontodisplaythedeletebookmenuandhandleuserchoices
324 defdeleteBookMenu():
325 #Deletebookmenuoptions
326 print("1.Home")
327 print("2.Back")
328 print("3.Exit")
329 userChoice=int(input("EnteryourChoicetoContinue:"))
330 print(" ")

16|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 #GetuserinputforthebookIDtobe deleted
349 bookId=int(input("EntertheBookID:"))
350 choice=input("AreyousuretodeletetheBook?(Yes/No):") print(" ")
351
352 c.execute("SELECTbookIdFROMbooks")
353 result = c.fetchall()
354 db.commit()
355
356 ifchoice.lower()in["yes","y"]: if
357 (bookId,) in result:
358 # Execute SQL query to delete the book from the database
359 c.execute("DELETEFROMbooksWHEREbookId=%s",(bookId,))
360 db.commit()
361
362 #Notifytheuserthatthebookhasbeendeletedsuccessfully
363 print("BookdeletedSuccessfully!")
364 print("--------------------------"
365 )
366 deleteBookMenu()
367 else:
368 print(
369 f'Thebookofbookid"{bookId}"doesnotavailableinthe digital
370 library.'
371 )
372 print("--------------------------")
373 deleteBookMenu()
374 elif choice.lower() in ["no", "n"]:
375 print(" "
376 )
377 print("BookNotDeleted!")
378 print("--------------------------")
379 deleteBookMenu()
380 else:
381 validOption()
382
383
384 #Updatebookmenuoptions
385 defupdateBookMenu():
386 print("1. Home")
387 print("2.Back")
388 print("3.Exit")
389 userChoice=int(input("EnteryourChoicetoContinue:"))
390 print(" ")
391
392 #Userchoiceshandling
393 ifuserChoice==1:
394 home()
395 elifuserChoice==2:
396 updateUser()
elifuserChoice==3:

17|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 )
415 print("1. Update the Book ID")
416 print("2.UpdatetheBookName")
417 print("3.UpdatetheBookPublicationYear")
418 print("4. Update the Book Author Name")
419 print("5. Home")
420 print("6.Back")
421 print("7.Exit")
422 userChoice=int(input("EnteryourChoicetoContinue:"))
423 print(" ")
424
425 c.execute("SELECTbookIdFROMbooks")
426 result = c.fetchall()
427 db.commit()
428
429 #Userchoiceshandling
430 ifuserChoice==1:
431 currentBookId=int(input("EntertheCurrentBookID:")) newBookId =
432 int(input("Enter the New Book ID : "))
433
434 if(currentBookId,)inresult:
435 #ExecuteSQLquerytoupdatetheBookID
436 c.execute(
437 "UPDATEbooksSETbookId=%sWHEREbookId=%s",(newBookId,
438 currentBookId)
439 )
440 db.commit()
441
442 print("BookIDchangedSuccessfully!")
443 print("--------------------------")
444 updateBookMenu()
445 else:
446 notBook(currentBookId)
447
448 elifuserChoice==2:
449 bookId = int(input("Enter the Book ID : "))
450 newBookName=input("EntertheNewBookName:")
451
452 if(bookId,)inresult:
453 #ExecuteSQLquerytoupdatetheBookName
454 c.execute(
455 "UPDATEbooksSETbookName=%sWHEREbookId=%s", (newBookName,
456 bookId)
457 )
458 db.commit()
459
460 print("BookNamechangedSuccessfully!")
461 print("--------------------------")
462 updateBookMenu()
else:

18|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 c.execute(
472 "UPDATEbooksSETpublicationYear=%sWHEREbookId=%s",
473 (newPublicationYear, bookId),
474 )
475 db.commit()
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 c.execute(
488 "UPDATEbooksSETauthor=%sWHEREbookId=%s",
489 (newAuthor, bookId),
490 )
491 db.commit()
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("1.Home")
512 print("2.Back")
513 print("3.Exit")
514 userChoice=int(input("EnteryourChoicetoContinue:"))
515 print(" ")
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 #Functiontoissueabook

19|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 c.execute("SELECTuserIdFROMusers")
538 result1=c.fetchall()
539 c.execute("SELECTbookIdFROMbooks")
540 result2=c.fetchall()
541 c.execute("SELECTissueStatusFROMbooksWHEREbookId=%s",(bookId,))
542 result3=c.fetchall()
543 db.commit()
544
545 if(userId,)inresult1:
546 if(bookId,)inresult2:
547 #Checkifthebookisnotalreadyissued
548 ifresult3[0][0]=="notissued":
549 #ExecuteSQLqueriestoupdatebookdetailsandmarkitas
550 issued
551 c.execute(
552 "UPDATEbooksSETissueDate=CURRENT_DATEWHEREbookId
553 =%s",
554 (bookId,),
555 )
556 c.execute(
557 "UPDATEbooksSETissueTime=CURRENT_TIMEWHEREbookId
558 =%s",
559 (bookId,),
560 )
561 c.execute(
562 "UPDATEbooksSETissueStatus='issued'WHEREbookId =
563 %s",
564 (bookId,),
565 )
566 c.execute(
567 "UPDATEbooksSETreturnDate=NULLWHEREbookId=%s",
568 (bookId,)
569 )
570 c.execute(
571 "UPDATEbooksSETreturnTime=NULLWHEREbookId=%s",
572 (bookId,)
573 )
574 c.execute(
575 "UPDATEbooksSETissuedUserId=%sWHEREbookId=%s",
576 (userId,bookId),
577 )
578 db.commit()
579 c.execute(
580
"selectissuedUserId,bookName,issueDate,issueTimefrom
581
books where bookId=%s",
582
583 (bookId,),
584 )
585 result=c.fetchall()
586 c.execute(
587 "INSERT INTO issuedBooksDetails (userId,
bookId,bookName,issueDate,issueTime)VALUES(%s,%s,%s,%s,%s)",
588
(result[0][0],bookId,result[0][1],result[0][2],
589
590 result[0][3]), )
591 db.commit()
592
593 print("--------------------------")
594 print(

20|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("2.Back")
626 print("3.Exit")
627 userChoice=int(input("EnteryourChoicetoContinue:"))
628 print(" ")
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 #Functiontoreturnabook
642 defreturnBook():
643 print(" ")
644 print("ReturnBook")
645 print(" ")
646 bookId=int(input("EntertheBookIDtobeReturned:"))
647
648 #ExecuteSQLquerytochecktheissuestatusofthebook
649 c.execute("SELECTbookIdFROMbooks") result1
650 = c.fetchall()
651 c.execute("SELECTissueStatusFROMbooksWHEREbookId=%s",(bookId,))
652 result2 = c.fetchall()
653
654 db.commit()
655
656 if(bookId,)inresult1:
657 #Checkifthebookis issued
658 ifresult2[0][0]=="issued":
659 #ExecuteSQLqueriestoupdatebookdetailsandmarkitas
660

21|Page
661 returned
662 c.execute(
663 "UPDATEbooksSETreturnDate=CURRENT_DATEWHEREbookId=
664 %s",
665 (bookId,),
666 )
667 c.execute(
668 "UPDATEbooksSETreturnTime=CURRENT_TIMEWHEREbookId=
669 %s",
670 (bookId,),
671 )
672 c.execute(
673 "UPDATEbooksSETissueStatus='notissued'WHEREbookId=
674 %s",
675 (bookId,),
676 )
677 db.commit()
678 c.execute(
679 "selectissuedUserId,returnDate,returnTimefrombookswhere
680 bookId=%s",
681 (bookId,),
682 )
683 result=c.fetchall()

685 "UPDATEissuedBooksDetailsSETreturnDate=%s,returnTime
686 =%sWHEREuserId=%sANDbookId=%s",
687 (result[0][1],result[0][2],result[0][0],bookId),
688 )
689
690 db.commit()
691 c.execute(
692 "UPDATEbooksSETissuedUserId=NULLWHEREbookId=%s",
693 (bookId,)
694 )
695 db.commit()
696
697 print(f'Thebookofbookid"{bookId}"isreturned successfully.')
698
699 c.execute("selectissueDatefrombooksWHEREbookId=%s",
700 (bookId,))
701 issueDate=c.fetchall()
702 c.execute("selectreturnDatefrombooksWHEREbookId=%s",
703 (bookId,))
704 returnDate=c.fetchall()
705 db.commit()
706
707 c.execute("UPDATEbooksSETissueDate=NULLWHEREbookId=
708 %s",(bookId,))
709 c.execute("UPDATEbooksSETissueTime=NULLWHEREbookId=
710 %s",(bookId,))
711 c.execute("UPDATEbooksSETreturnDate=NULLWHEREbookId=
712 %s",(bookId,))
713 c.execute("UPDATEbooksSETreturnTime=NULLWHEREbookId=
714 %s",(bookId,))
715 db.commit()
716
717 d1 = datetime.strptime(f"{issueDate[0][0]}", "%Y-%m-%d")
718 d2=datetime.strptime(f"{returnDate[0][0]}","%Y-%m-%d")
719 dateDifference = d1 - d2
720
721 ifdateDifference.days>14:
722 extraDays=dateDifference.days-14 fine
723 = extraDays * 5
724 print("Fine(inRs.):",fine) c.execute(
725
726

22|Page
727 "updateissuedBooksDetailssetfineInRs=%swhere userId=%s
728 and bookId=%s",
729 (fine,result[0][0],bookId),
730 )
731 db.commit()
732 else:
733 fine=0*5
734 print("Fine(inRs.):",fine) c.execute(
735 "updateissuedBooksDetailssetfineInRs=%swhere userId=%s
736 and bookId=%s",
737 (fine,result[0][0],bookId),
738 )
739 db.commit()
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("1.Home")
760 print("2.Back")
761 print("3.Exit")
762 userChoice=int(input("EnteryourChoicetoContinue:"))
763 print(" ")
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 #Functiontoaddanewuser
777 defaddUser():
778 print(" ")
779 print("AddUser")
780 print(" ")
781 #Getuserinputforuserdetails
782 userId=int(input("EntertheUserID:"))
783 userName = 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 c.execute("SELECTuserIdFROMusers")
790 result = c.fetchall()
791 db.commit()
792

23|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 c.execute(
803 "INSERTINTOusers(userId,userName,phoneNumber,emailId,
804 password) VALUES (%s, %s, %s, %s, %s)",
805 (userId,userName,userPhoneNumber,userEmailId,password),
806 )
807 db.commit()
808
809 #Notifytheuserthattheuserhasbeenaddedsuccessfully
810 print(" ")
811 print("User added successfully!")
812 print(" "
813 )
814 addUserMenu()
815
816
817 #Functiontodisplaythedeleteusermenuandhandleuserchoices
818 defdeleteUserMenu():
819 #Deleteusermenuoptions
820 print("1.Home")
821 print("2.Back")
822 print("3.Exit")
823 userChoice=int(input("EnteryourChoicetoContinue:"))
824 print(" ")
825
826 #Userchoiceshandling
827 ifuserChoice==1:
828 home()
829 elifuserChoice==2:
830 modifyUser()
831 elifuserChoice==3:
832 exiting()
833 else:
834 validOption()
835
836
837 #Functiontodeleteauser
838 defdeleteUser():
839 print(" ")
840 print("DeleteUser")
841 print(" ")
842 #GetuserinputfortheuserIDtobe deleted
843 userId=int(input("EntertheUserID:"))
844 choice=input("AreyousuretodeletetheUser?(Yes/No):")
845
846 c.execute("SELECTuserIdFROMusers")
847 result = c.fetchall()
848 db.commit()
849
850 ifchoice.lower()in["yes","y"]: if
851 (userId,) in result:
852 c.execute("DELETEFROMusersWHEREuserId=%s",(userId,))
853 db.commit()
854
855 #Notifytheuserthattheuserhasbeendeletedsuccessfully
856 print("Userdeletedsuccessfully!")
857 print("--------------------------"
)
858
deleteUserMenu()

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

25|Page
925 newUserId=int(input("EntertheNewUserID:"))
926
927 if(currentUserId,)inresult:
928 c.execute(
929 "updateuserssetuserId=%swhereuserId=%s",(newUserId,
930 currentUserId)
931 )
932 db.commit()
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: c.execute(
946 "updateuserssetuserName=%swhereuserId=%s", (newUserName,
947 userId)
948 )
949 db.commit()
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: c.execute(
963 "updateuserssetphoneNumber=%swhereuserId=%s",
964 (newPhoneNumber, userId),
965 )
966 db.commit()
967
968 print("UserPhoneNumberchangedSuccessfully!")
969 print("--------------------------")
970 updateUserMenu()
971 else:
972 notUser(userId)
973
974 elifuserChoice==4:
975 #UpdateuseremailID
976 userId=int(input("EntertheCurrentUserID:"))
977 newEmailId = input("Enter the New Email ID : ")
978
979 if(userId,)inresult: c.execute(
980 "updateuserssetemailId=%swhereuserId=%s",(newEmailId,
981 userId)
982 )
983 db.commit()
984
985 print("UserEmailIDchangedSuccessfully!")
986 print("--------------------------")
987 updateUserMenu()
988
989
990

26|Page
991 else:
992 notUser(userId)
993
994 elifuserChoice==5:
995 #Updateuserpassword
996 userId=int(input("EntertheCurrentUserID:"))
997 newPassword = input("Enter the New Password : ")if
998 (userId,) in result:
999 c.execute(
1000 "updateuserssetpassword=%swhereuserId=%s",
1001 (newPassword, userId)
1002 )
1003 db.commit()
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 #Gobacktothepreviousmenu
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("2.DeleteUser")
1032 print("3.UpdateUserDetails")
1033 print("4. Home")
1034 print("5.Back")
1035 print("6.Exit")
1036 #Getuserchoice
1037 userChoice=int(input("EnteryourChoicetoContinue:"))
1038 print(" ")
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 #Returntothepreviousmenu
1055 admin()
1056 elifuserChoice==6:

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

28|Page
1123 searchUsers()
1124 elifuserChoice==3:
1125 exiting()
1126 else:
1127 validOption()
1128
1129
1130 #FunctiontosearchusersbyID
1131 defsearchUsersbyId():
1132 print("--------------------------")
1133 print("Search Users by User ID")
1134 print(" "
1135 )
1136 #GetuserIDtosearch
1137 userId=int(input("EntertheUserIDtosearchtheUser:"))
1138
1139 #Searchfortheuserinthedatabase
1140 c.execute("SELECT*FROMusersWHEREuserId=%s",(userId,)) result =
1141 c.fetchall()
1142 db.commit()
1143
1144 ifresult:
1145 #Displayuserinformationiffound
1146 print(f'UserenrolledintheDigitalLibrarywiththeUserID "{userId}"
1147 is :')
1148 i=0
1149 forrowinresult: i
1150 += 1
1151 r=length(i)
1152 print(f"{i}.UserID:{row[0]}")
1153 print(""*r+f"UserName:{row[1]}")
1154 print(""*r+f"PhoneNumber:{row[2]}")
1155 print(""*r+f"EmailID:{row[3]}")
1156 print(""*r+f"AdminStatus:{row[5]}")
1157 print("--------------------------")
1158 searchUsersMenu()
1159
1160 else:
1161 #Handlecasewhennouserisfound
1162 print(f'Nouserfoundwiththeuserid"{userId}".')
1163 print(" ")
1164 searchUsersMenu()
1165
1166
1167 #Functiontosearchusersbykeyword
1168 defsearchUsersbyKeyword():
1169 print(" ")
1170 print("Search Users by Keyword")
1171 print(" "
1172 )
1173 #Getkeywordinputfromtheuser
1174 keyword=input("EnteraKeywordtosearchUsers:")
1175
1176 #Searchforuserswiththegivenkeywordintheirnames
1177 c.execute(
1178 "SELECT*FROMusersWHEREuserNameLIKE'%{}%'ORDERBY
1179 userId".format(keyword)
1180 )
1181 result=c.fetchall()
1182 db.commit()
1183
1184 ifresult:
1185 #Displayuserinformationifusersarefound
1186 print(
1187 f'UsersenrolledintheDigitalLibrarywiththeKeyword
1188 "{keyword}" are :'
)
i=0
29|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]}")
1197 print("--------------------------")
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("1.SearchbyUserID")
1214 print("2.SearchbyKeyword")
1215 print("3. Home")
1216 print("4.Back")
1217 print("5.Exit")
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:
1229 admin()
1230 elifuserChoice==5:
1231 exiting()
1232 else:
1233 validOption()
1234
1235
1236 #Functiontomodifybooks
1237 defmodifyBook():
1238 print(" ")
1239 print("ModifyBook")
1240 print(" ")
1241 #Bookmodificationmenu
1242 print("1. Add Book")
1243 print("2. Delete Book")
1244 print("3.UpdateBookDetails")
1245 print("4. Home")
1246 print("5.Back")
1247 print("6.Exit")
1248 userChoice=int(input("EnteryourChoicetoContinue:"))
1249 print(" ")
1250
1251 #Userchoiceshandling
1252 ifuserChoice==1:
1253 addBook()
1254 elifuserChoice==2:

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

31|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 c.execute("SELECTnoteNumberFROMnoteswhereuserId=%s",(USERID,)) result =
1332 c.fetchall()
1333 db.commit()
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 c.execute(
1346 "INSERT INTO notes (userId, noteNumber, noteTitle,
1347 noteDescription,updateDate,updateTime)VALUES(%s,%s,%s,%s,
1348 CURRENT_DATE, CURRENT_TIME)",
1349 (USERID,noteNumber,noteTitle,noteDescription),
1350 )
1351 db.commit()
1352
1353 print(f'Thenoteofnotenumber"{noteNumber}"isadded
1354 successfully.')
1355 print(" ")
1356 addNoteMenu()
1357
1358
1359 #Functiontodisplaythedeletenotemenuandhandleuserchoices
1360 defdeleteNoteMenu():
1361 #Displaymenuoptionsafterdeletingthenote
1362 print("1.Home")
1363 print("2.Back")
1364 print("3.Exit")
1365 #Getuserchoice
1366 userChoice=int(input("EnteryourChoicetoContinue:"))
1367 print(" ")
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 #Functiontodeleteanote
1381 defdeleteNote():
1382 print(" ")
1383 print("DeleteNote")
1384 print(" ")
1385 #Getnotenumbertobedeletedfromtheuser
1386 noteNumber=int(input("EntertheNoteNumbertoDeletetheNote:"))

32|Page
1387 choice=input("AreyousuretodeletetheNote?(Yes/No):") print("
1388 ")
1389
1390 c.execute("SELECTnoteNumberFROMnoteswhereuserId=%s",(USERID,)) result =
1391 c.fetchall()
1392 db.commit()
1393
1394 ifchoice.lower()in["yes","y"]: if
1395 (noteNumber,) in result:
1396 #ExecuteSQLquerytodeletethenotefromthedatabase
1397 c.execute(
1398 "deleteFROMnotesWHEREuserId=%sandnoteNumber=%s", (USERID,
1399 noteNumber),
1400 )
1401 db.commit()
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 choice.lower() in ["no", "n"]:
1415 print(" "
1416 )
1417 print("NoteNotDeleted!")
1418 print(" ")
1419 deleteNoteMenu()
1420 else:
1421 validOption()
1422
1423
1424 #Functiontodisplaytheupdatenotesmenuandhandleuserchoices
1425 defupdateNotesMenu():
1426 print("1. Home")
1427 print("2.Back")
1428 print("3.Exit")
1429 #Getuserchoice
1430 userChoice=int(input("EnteryourChoicetoContinue:"))
1431 print(" ")
1432
1433 #Handleuserchoices
1434 ifuserChoice==1:
1435 home()
1436 elifuserChoice==2:
1437 updateNotes()
1438 elifuserChoice==3:
1439 exiting()
1440 else:
1441 validOption()
1442
1443
1444 defnotNote(noteNumber):
1445 print(
1446 f'Thenoteofnotenumber"{noteNumber}"doesnotexistsinthe digital
1447 library.'
1448 )
1449 print(" ")
1450 updateNotesMenu()
1451
1452

33|Page
1453 #Functiontoupdateanote
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("3.UpdatetheNoteDescription")
1462 print("4. Home")
1463 print("5.Back")
1464 print("6.Exit")
1465 #Getuserchoice
1466 userChoice=int(input("EnteryourChoicetoContinue:"))
1467 print(" ")
1468
1469 c.execute("SELECTnoteNumberFROMnoteswhereuserId=%s",(USERID,)) result =
1470 c.fetchall()
1471 db.commit()
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 c.execute(
1482 "updatenotessetupdateDate=CURRENT_DATEwhereuserId=%s and
1483 noteNumber=%s",
1484 (USERID,currentNoteNumber),
1485 )
1486 c.execute(
1487 "updatenotessetupdateTime=CURRENT_TIMEwhereuserId=%s and
1488 noteNumber=%s",
1489 (USERID,currentNoteNumber),
1490 )
1491 #UpdateNoteNumber
1492 c.execute(
1493 "updatenotessetnoteNumber=%swhereuserId=%sand
1494 noteNumber=%s",
1495 (newNoteNumber,USERID,currentNoteNumber),
1496 )
1497 db.commit()
1498
1499 print("NoteNumberchangedSuccessfully!")
1500 print("--------------------------")
1501 updateNotesMenu()
1502 else:
1503 notNote(currentNoteNumber)
1504
1505 elifuserChoice==2:
1506 #UpdateNoteTitle
1507 noteNumber=int(input("EntertheCurrentNoteNumber:"))
1508 newTitle = input("Enter the New Note Title : ")
1509
1510 if(noteNumber,)inresult: #
1511 Update date and time
1512 c.execute(
1513 "updatenotessetupdateDate=CURRENT_DATEwhereuserId=%s and
1514 noteNumber=%s",
1515 (USERID,noteNumber),
1516 )
1517 c.execute(
1518 "updatenotessetupdateTime=CURRENT_TIMEwhereuserId=%s

34|Page
1519 andnoteNumber=%s",
1520 (USERID,noteNumber),
1521 )
1522 #UpdateNoteTitle
1523 c.execute(
1524 "updatenotessetnoteTitle=%swhereuserId=%sand
1525 noteNumber=%s",
1526 (newTitle,USERID,noteNumber),
1527 )
1528 db.commit()
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 c.execute(
1544 "updatenotessetupdateDate=CURRENT_DATEwhereuserId=%s and
1545 noteNumber=%s",
1546 (USERID,noteNumber),
1547 )
1548 c.execute(
1549 "updatenotessetupdateTime=CURRENT_TIMEwhereuserId=%s and
1550 noteNumber=%s",
1551 (USERID,noteNumber),
1552 )
1553 #UpdateNoteDescription
1554 c.execute(
1555 "updatenotessetnoteDescription=%swhereuserId=%sand
1556 noteNumber=%s",
1557 (newDescription,USERID,noteNumber),
1558 )
1559 db.commit()
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")print("2.
1584 Delete Note")

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

36|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("2.Back")
1662 print("3.Exit")
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 c.execute("SELECT*FROMnotesWHEREbookId=%s",(noteNumber,))
1683 result = c.fetchall()
1684 db.commit()
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]}")
1699 print("--------------------------")
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 )
1715 #Getkeywordfromuser
1716 keyword=input("EnteraKeywordtosearchNotes:")

37|Page
1717 #ExecuteSQLquerytofetchnoteswiththegivenkeywordinthetitle
1718 c.execute(
1719 "SELECT*FROMnotesWHEREnoteTitleLIKE'%{}%'ORDERBY
1720 noteNumber".format(
1721 keyword
1722 )
1723 )
1724 result=c.fetchall()
1725 db.commit()
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]}")
1740 print("--------------------------")
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("1.SearchbyNoteNumber")
1757 print("2. Search by Keyword")
1758 print("3. Home")
1759 print("4.Back")
1760 print("5.Exit")
1761 #Getuserchoice
1762 userChoice=int(input("EnteryourChoicetoContinue:"))
1763 print(" ")
1764
1765 #Handleuserchoices
1766 if userChoice == 1:
1767 searchNotesbynoteNumber()
1768 elif userChoice == 2:
1769 searchNotesbyKeyword()
1770 elifuserChoice==3:
1771 notes()
1772 elifuserChoice==4:
1773 modifyNote()
1774 elifuserChoice==5:
1775 exiting()
1776 else:
1777 validOption()
1778
1779
1780 #Functiontodisplaythechangeadminmenuandhandleuserchoices
1781 defchangeAdminMenu():
1782 print("1. Home")

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

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

40|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 )
1936 userId = int(input("Enter the User ID : "))
1937 password=input("EntertheUserPassword:")
1938
1939 #CheckiftheentereduserIDexists
1940 c.execute("SELECTpasswordFROMusersWHEREuserId=%s",(userId,)) result =
1941 c.fetchall()
1942 db.commit()
1943
1944 #IftheentereduserIDisnotvalid,printanerrormessage
1945 iflen(result)==0:
1946 print(" ")
1947 print("Pleaseenteravaliduserid!")
1948 print(" ")
1949 else:
1950 #Iftheenteredpasswordmatchestheuser'spassword
1951 ifpassword==result[0][0]:
1952 global USERID
1953 USERID=userId
1954 print("\033[0;35m--------------------------\033[0;0m")
1955 print("\033[0;36mUserisverifiedsuccessfully.\033[0;0m")
1956 print("\033[0;35m--------------------------\033[0;0m")
1957 user()#Calltheusermenu
1958 else:
1959 print("PleaseEnteraValidPassword!")
1960 print("--------------------------")
1961
1962
1963 #Functiontosearch&displaythewikipediaarticles
1964 defwikipediaArticles():
1965 #Functiontofetcharticledetails
1966 deffetchingArticle(keyword,articleLength=1500):
1967 #CreatingaWikipediaAPIobject
1968 wiki=wikipediaapi.Wikipedia(language="en",user_agent="digital-
1969 library/1.1")
1970 #Fetchingthepageforthegivensearchquery
1971 page=wiki.page(keyword)
1972
1973 #Checkingifthepageexists
1974 ifnotpage.exists():
1975 print(
1976 f'Sorry,theWikipediaArticleforthekeyword"{keyword}"
1977 doesnotexists.'
1978 )
1979 print("--------------------------")
1980 else:
#Displayingarticletitle

41|Page
1981 print("Title:")
1982 print(page.title)
1983 print("URL:")
1984 print(page.fullurl)
1985 #Displayingasummaryofthearticlewithinthespecified
1986 length
1987 print("Summary:")
1988
1989 start=0
1990 end=157
1991 article=page.summary[: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 : articleLength=int(input("EntertheArticleLength:"))
2006
2007 print(" ")

2008 #Callingthefunctiontofetchanddisplaythearticle
2009 fetchingArticle(keyword, articleLength)
2010
2011 userMenu()
2012
2013
2014
2015 #Functiontosearch&displaythenews
2016 defnews():
2017 deffetchNews(apiKey,country="in",category="science",numArticles=5):
2018 url = f"https://newsapi.org/v2/top-headlines"
2019 params={
2020 "apiKey": apiKey,
2021 "country": country,
2022 "category": category,
2023 "pageSize":numArticles,
2024 }
2025 response=requests.get(url,params=params)
2026
2027 ifresponse.status_code==200:
2028 news_data=response.json()
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}:{response.text}")
2039 print("--------------------------")
2040
2041 2046
2042
2043
2044
2045
42|Page
A
P
I
_
K
E
Y
=
"
Y
O
U
R
_
A
P
I
_
K
E
Y
"

p
r
i
n
t
(
"

"
)
p
r
i
n
t
(
"
N
e
w
s
"
)
p
r
i
n
t
(
"

"
)

prin
t("C
ount
ryco
desa
re:"
)

43|Page
2047 print("https://newsapi.org/sources")
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:"))
2055 print(" ")
2056
2057 fetchNews(API_KEY,country,category,numArticles)
2058
2059 userMenu()
2060
2061
2062 #Functiontodisplaytheissuedbooksdetailsofauser
2063 defissuedBooksDetails():
2064 print(" ")
2065 print("Issued Books Details")
2066 print(" "
2067 )
2068 returnPolicy()
2069
2070 c.execute(
2071 "SELECT*FROMissuedBooksDetailsWHEREuserId=%sORDERBYbookId", (USERID,)
2072 )
2073 result=c.fetchall()
2074 db.commit()
2075
2076 ifresult==[]:
2077 print("NoBooksIssued!")
2078 print("--------------------------")
2079 userMenu()
2080
2081 else:
2082 i=0
2083 forrowinresult: i
2084 += 1
2085 r=length(i)
2086 print(f"{i}.BookID:",row[1])
2087 print(""*r+"BookName:",row[2])
2088 print(""*r+"IssueDate:",row[3])
2089 print(""*r+"IssueTime:",row[4])
2090 print(""*r+"ReturnDate:", row[5])
2091 print(""*r+"ReturnTime:", row[6])
2092 print(""*r+"Fine(inRs.):",row[7]) print("
2093 ---------------------------------")
2094 userMenu()
2095
2096
2097 #Functiontodisplaytheusermenu
2098 defuser():
2099 print(" ")
2100 print("User")
2101 print(" ")
2102 #CheckiftheentereduserIDexists
2103 c.execute('SELECTuserIdFROMusersWHEREadminStatus="admin"')
2104 result = c.fetchall()
2105 db.commit()
2106
2107 ifresult[0][0]==USERID:
2108 print("1.LoginintoAdminPanel")
2109 print("2.About the Library")
2110 print("3. News")
2111 print("4.WikipediaArticles")
2112 print("5.Display Books")

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

45|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("1.Admin")
2210 print("2.User")
2211 print("3.Exit")
2212 userChoice=int(input("EnteryourChoicetoContinue:"))
2213 print(" ")
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

46|Page
MySQL
Database

47|Page
LibraryDatabase:

BooksTable:

UsersTable:

48|Page
NotesTable:

IssuedBooksDetailsTable:

49|Page
Outputs

50|Page
Startingoftheprogram:

AdminAuthentication:

Addinganewuser:

51|Page
Updatinguserdetails:

Addinganewbook:

52|Page
Updatingbookdetails:

53|Page
UserAuthentication:

AboutLibrary:

54|Page
News:

WikipediaArticles:

55|Page
IssuedBooksDetails:

56|Page
Existingtheprogram:

57|Page
REFERENCES

1. News API
https://newsapi.org/
2. Wikipedia
https://www.wikipedia.org/
3. Python
https://www.python.org/
4. MySQL
https://www.mysql.com/
5. ANSIEscapeCodesinPython
 https://pypi.org/project/ansi/
 https://replit.com/talk/learn/ANSI-Escape-Codes-in-
Python/22803
 https://gist.github.com/rene-d/
9e584a7dd2935d0f461904b9f2950007

58|Page

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy