-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfunction.py
More file actions
1103 lines (1042 loc) · 49.4 KB
/
function.py
File metadata and controls
1103 lines (1042 loc) · 49.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#function.py
import mysql.connector
'''Library functions'''
#functions
def start1():
print(''' Welcome to DPS Senior Library
When in doubt, go to library!
Guidelines
General Rules
-No library material can be taken out of the library without permission. Unauthorized removal of anything belonging to the
library will be treated as theft and dealt accordingly.
-Any one who violates the rules and regulations of the library would be liable to lose the privilege of
library membership and may be debarred from using the library facilities.
-Suggestions on all aspects, of library services are welcome.
-The library remains open throughout the school timings but the books cannot be returned or issue during lunch break
(11:30-12:30)
-The library may be closed during non-academic days of school.
-No student will be allowed to avail library facility without valid ID card and library card. The borrower cards are not
transferable
-For availing library facility, students should be in proper uniform.
Issue/Return Rules
-Students are allowed to issue 2 maximum number of books, 15 maximum days of issue.
Fine for late return books/journals
-Books must be return on or before the due date otherwise the fine of Rs. 5 will be charged per day/book.
-At the time of deposition of late fine you must collect receipt for the payment from the library.
-Absence & illness are not acceptable excuses for exemption from paying overdue charges.
-If the Due Date falls on holiday declare by collage, then students may return their books on the next week on scheduled
day.
-User(s) has to return all issued books when he/ she is out of station for more than fifteen days.
-In spite of repeated reminders, if the book is not returned, the borrowing facility may be withdrawn for a period
-decided by the authority. Also, if the student fails to deposit the issued book for more than 60 days from the date of
due then he/she may have to pay the fine amount including the current MRP of the book.
Renewal of books
-Users can also renew the books again after the completion of charging period, subject to not being requested from
some other user.
Login for Academic Year 2021-22''');
user =input("User ID:")
password=input("Password:")
if user =="6230004" and password=="admin":
main()
else:
print("Invalid credentials")
def main():
print("Login Successful")
print()
print("1. Students details")
print("2. Books details")
print("3. Add books")
print("4. Delete books")
print("5. Submit books & Fine")
print("6. Issue book")
print("7. Total Penalty Collection")
print("8. Logout")
choice10=int(input("Enter your choice:"))
if choice10==1:
student2()
if choice10==2:
books()
if choice10==3:
add()
if choice10==4:
dell()
if choice10==5:
submit_books()
if choice10==6:
issue_books()
if choice10==7:
penalty()
if choice10==8:
start()
def start():
print(''' Welcome to DPS Senior Library
When in doubt, go to library!
Guidelines
General Rules
-No library material can be taken out of the library without permission. Unauthorized removal of anything belonging to the
library will be treated as theft and dealt accordingly.
-Any one who violates the rules and regulations of the library would be liable to lose the privilege of
library membership and may be debarred from using the library facilities.
-Suggestions on all aspects, of library services are welcome.
-The library remains open throughout the school timings but the books cannot be returned or issue during lunch break
(11:30-12:30)
-The library may be closed during non-academic days of school.
-No student will be allowed to avail library facility without valid ID card and library card. The borrower cards are not
transferable
-For availing library facility, students should be in proper uniform.
Issue/Return Rules
-Students are allowed to issue 2 maximum number of books, 15 maximum days of issue.
Fine for late return books/journals
-Books must be return on or before the due date otherwise the fine of Rs. 5 will be charged per day/book.
-At the time of deposition of late fine you must collect receipt for the payment from the library.
-Absence & illness are not acceptable excuses for exemption from paying overdue charges.
-If the Due Date falls on holiday declare by collage, then students may return their books on the next week on scheduled
day.
-User(s) has to return all issued books when he/ she is out of station for more than fifteen days.
-In spite of repeated reminders, if the book is not returned, the borrowing facility may be withdrawn for a period
-decided by the authority. Also, if the student fails to deposit the issued book for more than 60 days from the date of
due then he/she may have to pay the fine amount including the current MRP of the book.
Renewal of books
-Users can also renew the books again after the completion of charging period, subject to not being requested from
some other user.
Login for Academic Year 2021-22''');
user =input("User ID:")
password=input("Password:")
if user =="6230004" and password=="admin":
main()
else:
print("Invalid credentials")
def main1():
print("Login Successful")
print()
print("1. Students details")
print("2. Books details")
print("3. Add books")
print("4. Delete books")
print("5. Submit books & Fine")
print("6. Issue book")
print("7. Total Penalty Collection")
print("8. Logout")
choice10=int(input("Enter your choice:"))
if choice10==1:
student2()
if choice10==2:
books()
if choice10==3:
add()
if choice10==4:
dell()
if choice10==5:
submit_books()
if choice10==6:
issue_books()
if choice10==7:
penalty()
if choice10==8:
start()
def disabed_students():
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
mycursor.execute("SELECT * FROM disabed_students;")
myresult = mycursor.fetchall()
for x in myresult:
print(x)
print("1. Disable")
print("Go back")
c=int(input("Enter your choice:"))
if c==1:
dis_roll=int(input("Enter the Student's roll no. you want to disable or 0 to exit"))
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my_data=(dis_roll,)
q="SELECT * FROM all_students WHERE Ad_No=%s"
mycursor.execute(q,my_data)
myresult = mycursor.fetchone()
sql = "INSERT INTO disabed_students(Ad_No,Name,Class,Stream,Section,Phone_no,Status,Book_Issued,No_of_Books) VALUES (%s, %s,%s, %s,%s, %s,%s, %s,%s)"
mycursor.execute(sql, myresult)
mydb.commit()
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my_data=(dis_roll,)
q="UPDATE all_students SET status = 'DISABLED' WHERE AD_NO =%s"
mycursor.execute(q,my_data)
mydb.commit()
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my_data=(dis_roll,)
q="UPDATE disabed_students SET status = 'DISABLED' WHERE AD_NO =%s"
mycursor.execute(q,my_data)
mydb.commit()
print("Operation successful")
main1()
else:
student2()
def available_students():
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
mycursor.execute("SELECT * FROM all_students where STATUS='ENABLED';")
myresult = mycursor.fetchall()
for x in myresult:
print(x)
print("1. Enable")
print("Go back")
c=int(input("Enter your choice:"))
if c==1:
ava_roll=int(input("Enter the Student's roll no. you want to enable or 0 to exit"))
print("Operation successful")
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my_data=(ava_roll,)
q="UPDATE all_students SET status = 'ENABLED' WHERE AD_NO =%s"
mycursor.execute(q,my_data)
mydb.commit()
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my_data=(ava_roll,)
q="DELETE FROM disabed_students WHERE Ad_No=%s"
mycursor.execute(q,my_data)
mydb.commit()
print("Operation successful")
else:
student2()
def search_roll():
_roll=int(input("Enter the Student's roll no."))
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my_data=(_roll,)
q="SELECT Ad_No,Name,Class,Stream,Section,Phone_no,Status,No_of_Books FROM all_students WHERE Ad_No=%s"
mycursor.execute(q,my_data)
myresult = mycursor.fetchall()
for x in myresult:
print(x)
main1()
def search_name():
_name=input("Enter the Student's name")
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my_data=(_name,)
q="SELECT Ad_No,Name,Class,Stream,Section,Phone_no,Status,No_of_Books FROM all_students WHERE Name=%s"
mycursor.execute(q,my_data)
myresult = mycursor.fetchall()
for x in myresult:
print(x)
main1()
def search_class():
_class=input("Enter the Student's class")
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my_data=(_class,)
q="SELECT Ad_No,Name,Class,Stream,Section,Phone_no,Status,No_of_Books FROM all_students WHERE CLASS=%s"
mycursor.execute(q,my_data)
myresult = mycursor.fetchall()
for x in myresult:
print(x)
main1()
def search_stream():
_stream=input("Enter the Student's stream")
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my_data=(_stream,)
q="SELECT Ad_No,Name,Class,Stream,Section,Phone_no,Status,No_of_Books FROM all_students WHERE STREAM=%s"
mycursor.execute(q,my_data)
myresult = mycursor.fetchall()
for x in myresult:
print(x)
main1()
def all_students():
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
mycursor.execute("SELECT * FROM all_students;")
myresult = mycursor.fetchall()
for x in myresult:
print(x)
print("1. Search students")
print("Go back")
f=int(input("Enter your choice:"))
if f==1:
print("1. Search by Roll no.")
print("2. Search by Name")
print("3. Search by Class")
print("4. Search by Stream")
print("GO BACK")
choice1=int(input("Enter your choice:"))
if choice1==1:
search_roll()
elif choice1==2:
search_name()
elif choice1==3:
search_class()
elif choice1==4:
search_stream()
else:
student2()
else:
student2()
def student2():
print("1. Disable Students")
print("2. Available Students")
print("3. All Students")
print("4. Go back")
choice=int(input("Enter your choice:"))
if choice==1:
disabed_students()
if choice==2:
available_students()
if choice==3:
all_students()
else:
main1()
def search_code():
_code=int(input("Enter the Book's code no."))
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my_data=(_code,)
q="SELECT Code_No,Title,Subject,Author,Edition,Status,MRP,AD_NO FROM ISSUE_BOOKS WHERE Code_No=%s"
mycursor.execute(q,my_data)
myresult = mycursor.fetchall()
for x in myresult:
print(x)
main1()
def search_title():
_title=(input("Enter the Book's title"))
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my_data=(_title,)
q="SELECT Code_No,Title,Subject,Author,Edition,Status,MRP,AD_NO FROM ISSUE_BOOKS WHERE TITLE=%s"
mycursor.execute(q,my_data)
myresult = mycursor.fetchall()
for x in myresult:
print(x)
main1()
def search_subject():
_subject=input("Enter the Student's subject")
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my_data=(_subject,)
q="SELECT Code_No,Title,Subject,Author,Edition,Status,MRP,AD_NO FROM ISSUE_BOOKS WHERE SUBJECT=%s"
mycursor.execute(q,my_data)
myresult = mycursor.fetchall()
for x in myresult:
print(x)
main1()
def search_author():
_author=input("Enter the Student's author")
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my_data=(_author,)
q="SELECT Code_No,Title,Subject,Author,Edition,Status,MRP,AD_NO FROM ISSUE_BOOKS WHERE AUTHOR=%s"
mycursor.execute(q,my_data)
myresult = mycursor.fetchall()
for x in myresult:
print(x)
main1()
def issued_books():
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
mycursor.execute("SELECT * FROM issue_books;")
myresult = mycursor.fetchall()
for x in myresult:
print(x)
print("1. Search Issued Books")
print("Go back")
o=int(input("Enter your choice:"))
if o==1:
print("1. Search by Code no.")
print("2. Search by Title")
print("3. Search by Subject")
print("4. Search by Author")
choice2=int(input("Enter your choice:"))
if choice2==1:
search_code()
elif choice2==2:
search_title()
elif choice2==3:
search_subject()
elif choice2==4:
search_author()
else:
books()
else:
books()
def search_code1():
_code=int(input("Enter the Book's code no."))
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my_data=(_code,)
q="SELECT Code_No,Title,Subject,Author,Edition,Status,MRP FROM ALL_BOOKS WHERE STATUS='AVAILABLE' AND Code_No=%s"
mycursor.execute(q,my_data)
myresult = mycursor.fetchall()
for x in myresult:
print(x)
main1()
def search_title1():
_title=(input("Enter the Book's title"))
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my_data=(_title,)
q="SELECT Code_No,Title,Subject,Author,Edition,Status,MRP FROM ALL_BOOKS WHERE STATUS='AVAILABLE' AND TITLE=%s"
mycursor.execute(q,my_data)
myresult = mycursor.fetchall()
for x in myresult:
print(x)
main1()
def search_subject1():
_subject=input("Enter the Book's subject")
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my_data=(_subject,)
q="SELECT Code_No,Title,Subject,Author,Edition,Status,MRP FROM ALL_BOOKS WHERE STATUS='AVAILABLE' AND SUBJECT=%s"
mycursor.execute(q,my_data)
myresult = mycursor.fetchall()
for x in myresult:
print(x)
main1()
def search_author1():
_author=input("Enter the Book's author")
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my_data=(_author,)
q="SELECT Code_No,Title,Subject,Author,Edition,Status,MRP FROM ALL_BOOKS WHERE STATUS='AVAILABLE' AND AUTHOR=%s"
mycursor.execute(q,my_data)
myresult = mycursor.fetchall()
for x in myresult:
print(x)
main1()
def available_books():
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
mycursor.execute("SELECT * FROM all_books WHERE STATUS='AVAILABLE';")
myresult = mycursor.fetchall()
for x in myresult:
print(x)
print("1. Search Available Books")
print("GO Back")
c=int(input("Enter your choice:"))
if c==1:
print("1. Search by Code no.")
print("2. Search by Title")
print("3. Search by Subject")
print("4. Search by Author")
choice3=int(input("Enter your choice:"))
if choice3==1:
search_code1()
elif choice3==2:
search_title1()
elif choice3==3:
search_subject1()
elif choice3==4:
search_author1()
else:
books()
else:
books()
def search_code2():
_code=int(input("Enter the Book's code no."))
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my_data=(_code,)
q="SELECT Code_No,Title,Subject,Author,Edition,Status,MRP FROM ALL_BOOKS WHERE Code_No=%s"
mycursor.execute(q,my_data)
myresult = mycursor.fetchall()
for x in myresult:
print(x)
main1()
def search_title2():
_title=(input("Enter the Book's title"))
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my_data=(_title,)
q="SELECT Code_No,Title,Subject,Author,Edition,Status,MRP FROM ALL_BOOKS WHERE TITLE=%s"
mycursor.execute(q,my_data)
myresult = mycursor.fetchall()
for x in myresult:
print(x)
main1()
def search_subject2():
_subject=input("Enter the Book's subject")
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my_data=(_subject,)
q="SELECT Code_No,Title,Subject,Author,Edition,Status,MRP FROM ALL_BOOKS WHERE SUBJECT=%s"
mycursor.execute(q,my_data)
myresult = mycursor.fetchall()
for x in myresult:
print(x)
main1()
def search_author2():
_author=input("Enter the Book's author")
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my_data=(_author,)
q="SELECT Code_No,Title,Subject,Author,Edition,Status,MRP FROM ALL_BOOKS WHERE AUTHOR=%s"
mycursor.execute(q,my_data)
myresult = mycursor.fetchall()
for x in myresult:
print(x)
main1()
def all_books():
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
mycursor.execute("SELECT * FROM all_books;")
myresult = mycursor.fetchall()
for x in myresult:
print(x)
print("1. Search Available Books")
print("GO Back")
p=int(input("Enter your choice:"))
if p==1:
print("1. Search by Code no.")
print("2. Search by Title")
print("3. Search by Subject")
print("4. Search by Author")
choice4=int(input("Enter your choice:"))
if choice4==1:
search_code2()
elif choice4==2:
search_title2()
elif choice4==3:
search_subject2()
elif choice4==4:
search_author2()
else:
books()
else:
books()
def update_title():
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
up_books=int(input("Enter the Book's code no. you want to update or 0 to exit"))
my_data=(up_books,)
q="SELECT * FROM all_books WHERE Code_No=%s"
mycursor.execute(q,my_data)
myresult = mycursor.fetchone()
print(myresult)
title=input("Enter the new title:")
aaa=(title,up_books,)
mycursor = mydb.cursor()
q="UPDATE all_books SET title = %s WHERE Code_no = %s"
mycursor.execute(q,aaa)
mydb.commit()
print("Operation successful")
main1()
def update_subject():
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
up_books=int(input("Enter the Book's code no. you want to update or 0 to exit"))
my_data=(up_books,)
q="SELECT * FROM all_books WHERE Code_No=%s"
mycursor.execute(q,my_data)
myresult = mycursor.fetchone()
print(myresult)
subject=input("Enter the new subject:")
aaa=(subject,up_books,)
mycursor = mydb.cursor()
q="UPDATE all_books SET subject = %s WHERE Code_no = %s"
mycursor.execute(q,aaa)
mydb.commit()
print("Operation successful")
main1()
def update_author():
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
up_books=int(input("Enter the Book's code no. you want to update or 0 to exit"))
my_data=(up_books,)
q="SELECT * FROM all_books WHERE Code_No=%s"
mycursor.execute(q,my_data)
myresult = mycursor.fetchone()
print(myresult)
author=input("Enter the new author:")
aaa=(author,up_books,)
mycursor = mydb.cursor()
q="UPDATE all_books SET author = %s WHERE Code_no = %s"
mycursor.execute(q,aaa)
mydb.commit()
print("Operation successful")
main1()
def update_edition():
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
up_books=int(input("Enter the Book's code no. you want to update or 0 to exit"))
my_data=(up_books,)
q="SELECT * FROM all_books WHERE Code_No=%s"
mycursor.execute(q,my_data)
myresult = mycursor.fetchone()
print(myresult)
edition=input("Enter the new edition:")
aaa=(edition,up_books,)
mycursor = mydb.cursor()
q="UPDATE all_books SET edition = %s WHERE Code_no = %s"
mycursor.execute(q,aaa)
mydb.commit()
print("Operation successful")
main1()
def update_MRP():
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
up_books=int(input("Enter the Book's code no. you want to update or 0 to exit"))
my_data=(up_books,)
q="SELECT * FROM all_books WHERE Code_No=%s"
mycursor.execute(q,my_data)
myresult = mycursor.fetchone()
print(myresult)
MRP=input("Enter the new MRP:")
aaa=(MRP,up_books,)
mycursor = mydb.cursor()
q="UPDATE all_books SET MRP = %s WHERE Code_no = %s"
mycursor.execute(q,aaa)
mydb.commit()
print("Operation successful")
main1()
def new_books():
aa=int(input("Enter Code_No:"))
bb=input("Enter Title:")
cc=input("Enter Subject:")
dd=input("Enter Author:")
ee=input("Enter Edition:")
ff=input("Enter MRP:")
txt=(aa,bb,cc,dd,ee,ff)
print(txt)
pr=input("Do you want to continue? If yes, then enter y otherwise press any key")
if pr=='y':
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
sql = "INSERT INTO all_books(Code_No,title,subject,author,Edition,MRP) VALUES (%s,%s,%s,%s,%s,%s)"
myresult=(aa,bb,cc,dd,ee,ff)
mycursor.execute(sql, myresult)
mydb.commit()
print("Operation successful")
else:
add()
def update_books():
print("1. Update Title")
print("2. Update Subject")
print("3. Update Author")
print("4. Update Edition")
print("5. Update MRP")
print("Go Back")
choice6=int(input("Enter your choice:"))
if choice6==1:
update_title()
elif choice6==2:
update_subject()
elif choice6==3:
update_author()
elif choice6==4:
update_edition()
elif choice6==5:
update_MRP()
def add():
print("1. New Books")
print("2. Update Books")
print("GO BACK")
choice5=int(input("Enter your choice:"))
if choice5==1:
new_books()
if choice5==2:
update_books()
else:
main1()
def search_code3():
_code=int(input("Enter the Book's code no."))
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my_data=(_code,)
q="SELECT * FROM deleted_BOOKS WHERE Code_No=%s"
mycursor.execute(q,my_data)
myresult = mycursor.fetchall()
for x in myresult:
print(x)
main1()
def search_title3():
_title=(input("Enter the Book's title"))
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my_data=(_title,)
q="SELECT * FROM DELETED_BOOKS WHERE TITLE=%s"
mycursor.execute(q,my_data)
myresult = mycursor.fetchall()
for x in myresult:
print(x)
main1()
def search_subject3():
_subject=input("Enter the Book's class")
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my_data=(_subject,)
q="SELECT * FROM DELETED_BOOKS WHERE SUBJECT=%s"
mycursor.execute(q,my_data)
myresult = mycursor.fetchall()
for x in myresult:
print(x)
main1()
def search_author3():
_author=input("Enter the Book's author")
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my_data=(_author,)
q="SELECT * FROM DELETED_BOOKS WHERE AUTHOR=%s"
mycursor.execute(q,my_data)
myresult = mycursor.fetchall()
for x in myresult:
print(x)
main1()
def search_dd():
_dd=input("Enter the Book's date of deletion")
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my_data=(_dd,)
q="SELECT * FROM DELETED_BOOKS WHERE DELETEDDATE=%s"
mycursor.execute(q,my_data)
myresult = mycursor.fetchall()
for x in myresult:
print(x)
main1()
def search_reason():
_reason=input("Enter the Book's reason for deletion")
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my_data=(_reason,)
q="SELECT * FROM DELETED_BOOKS WHERE reason=%s"
mycursor.execute(q,my_data)
myresult = mycursor.fetchall()
for x in myresult:
print(x)
main1()
def books():
print("1. Issued Books")
print("2. Available Books")
print("3. All Books")
print("GO BACK")
choice=int(input("Enter your choice:"))
if choice==1:
issued_books()
if choice==2:
available_books()
if choice==3:
all_books()
else:
books()
def delete_books():
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
del_books=int(input("Enter the Book's code no. you want to delete or 0 to exit"))
my_data=(del_books,)
q="SELECT Code_No,Title,Subject,Author,Edition,MRP FROM all_books WHERE Code_No=%s"
mycursor.execute(q,my_data)
myresult = mycursor.fetchone()
print(myresult)
yt=input("Do you want to continue? If yes, enter y otherwise enter any key")
if yt=='y':
bbb=input("Enter date of delete:")
ccc=input("Enter reason of delete:")
jj=(bbb,ccc,)
ss=myresult+jj
sql = "INSERT INTO deleted_books(Code_No,Title,Subject,Author,Edition,MRP,DeletedDate,Reason) VALUES (%s,%s,%s,%s,%s,%s,%s,%s)"
mycursor.execute(sql,ss)
mydb.commit()
mycursor = mydb.cursor()
j="DELETE FROM ALL_BOOKS WHERE Code_No=%s"
mycursor.execute(j,my_data)
mydb.commit()
mycursor = mydb.cursor()
k="SELECT Code_No FROM ISSUE_BOOKS"
mycursor.execute(k)
myresult = mycursor.fetchone()
t=len(myresult)
for i in myresult[0:t]:
if i == del_books:
mycursor = mydb.cursor()
z="DELETE FROM ISSUE_BOOKS WHERE Code_No=%s"
mycursor.execute(z,my_data)
mydb.commit()
print("Operation Suceessful")
else:
dell()
def search_delete():
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
mycursor.execute("SELECT * FROM deleted_books;")
myresult = mycursor.fetchall()
for x in myresult:
print(x)
print("1.Search")
print("GO BACK")
ch=int(input("Enter your choice:"))
if ch==1:
print("1. Search by Code no.")
print("2. Search by Title")
print("3. Search by Subject")
print("4. Search by Author")
print("5. Search by Deleted Date")
print("6. Search by Reason")
print("GO BACK")
choice8=int(input("Enter your choice:"))
if choice8==1:
search_code3()
elif choice8==2:
search_title3()
elif choice8==3:
search_subject3()
elif choice8==4:
search_author3()
elif choice8==5:
search_dd()
elif choice8==6:
search_reason()
else:
dell()
else:
dell()
def dell():
print("1. Search Deleted Books")
print("2. Delete Books")
print("Go Back")
choice7=int(input("Enter your choice:"))
if choice7==1:
search_delete()
elif choice7==2:
delete_books()
else:
main1()
def issue_books():
print("1. Issue Book")
print("GO BACK")
we=int(input("Enter your choice:"))
ww=[]
if we==1:
_issue=int(input("Enter the Book's Code No you want to issue"))
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
k="SELECT Code_No FROM ISSUE_BOOKS"
mycursor.execute(k)
myresult = mycursor.fetchall()
#print(myresult)
for row in myresult:
p=int(row[0])
print(p)
if p==_issue:
print("Sorry! Books already issued")
issue_books()
break
else:
_adno=int(input("Enter the Student's Admission No to whom you want to issue"))
ap=[]
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
l="SELECT Ad_No FROM disabed_students"
mycursor.execute(l)
myresult = mycursor.fetchall()
for i in myresult:
q=int(i[0])
if q == _adno:
print("Sorry! Student disabled. Cannot issue book")
issue_books()
else:
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
ww=(_adno,)
p="SELECT No_of_Books FROM all_students where Ad_No=%s"
mycursor.execute(p,ww)
myresult = mycursor.fetchall()
for oo in myresult:
if oo[0]<1:
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my=("ISSUED",_issue,)
cc="UPDATE all_books SET STATUS =%s WHERE Code_no = %s"
mycursor.execute(cc,my)
mydb.commit()
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my_data=(_issue,)
q="SELECT Code_No,Title,Subject,Author,Edition,MRP FROM ALL_BOOKS WHERE Code_No=%s"
mycursor.execute(q,my_data)
myre = mycursor.fetchone()
print(myre)
bbbb=input("Enter date of issue:")
yy=(bbbb,)
mm=myre+yy
sql = "INSERT INTO submit_books(Code_No,Title,Subject,Author,Edition,MRP,DateofIssue) VALUES (%s,%s,%s,%s,%s,%s,%s)"
mycursor.execute(sql,mm)
mydb.commit()
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my_data=(_issue,)
q="SELECT Code_No,Title,Subject,Author,Edition,MRP,status FROM ALL_BOOKS WHERE Code_No=%s"
mycursor.execute(q,my_data)
my_da = mycursor.fetchone()
qq="INSERT INTO ISSUE_BOOKS(Code_No,Title,Subject,Author,Edition,MRP,status) VALUES (%s,%s,%s,%s,%s,%s,%s)"
mycursor.execute(qq,my_da)
mydb.commit()
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my_dt=(_adno,_issue)
ff="UPDATE issue_books SET Ad_no =%s WHERE Code_no = %s"
mycursor.execute(ff,my_dt)
mydb.commit()
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my_dd=(_adno,_issue)
ff="UPDATE submit_books SET Ad_no =%s WHERE Code_no = %s"
mycursor.execute(ff,my_dd)
mydb.commit()
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
my=(_issue, _adno, )
ii="UPDATE all_students SET Book_Issued =%s WHERE Ad_no = %s"
mycursor.execute(ii,my)
mydb.commit()
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
m=(1,_adno, )
ii="UPDATE all_students SET No_of_Books = %s WHERE Ad_no = %s"
mycursor.execute(ii,m)
mydb.commit()
print("Operation Suceessful")
main1()
break
else:
print("No. of Issued Books exceeded")
issue_books()
else:
main1()
def submit_books():
print("1. Submit Book")
print("GO BACK")
at=[]
we=int(input("Enter your choice:"))
if we==1:
_submit=int(input("Enter the Book's Code No you want to submit"))
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
k="SELECT Code_No FROM ISSUE_BOOKS"
mycursor.execute(k)
myresult = mycursor.fetchall()
for row in myresult:
p=int(row[0])
if p==_submit:
_dos=input("Enter the Book's date of submission")
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
q1=(_submit,)
k="SELECT DateofIssue FROM SUBMIT_BOOKS where Code_No=%s"
mycursor.execute(k,q1)
myresult = mycursor.fetchall()
for row in myresult:
a=row[0]
mydb = mysql.connector.connect(host="localhost",user="root",password="library",database="library")
mycursor = mydb.cursor()
q2=(_dos, a, )
k="SELECT DATEDIFF(%s,%s)"
mycursor.execute(k,q2)
myresult = mycursor.fetchall()
for row in myresult:
t1=int(row[0])
if t1<0:
print("Invalid data for submission")
submit_books()
else:
if t1<=7:
print("No Penalty")
final=0
elif t1>7 and t1<=60:
print("Sorry!, Late to submit penalty will be charged")
g=t1-7
final=g*5
print("Your total penalty is",final)
elif t1>60:
print("Sorry!, too late to submit penalty will be charged along with MRP")
g=t1-7