RAJKIYA PRATHIBA VIKAS VIDYALAYA
DELHI – 110092
SESSION – 2024-25
COMPUTER PROJECT ON
Library Management
NAME: Ahad Ansari,Manish Kumar,Mohit Binjola
CLASS : XII A
CBSE ROLL NO :12129,12131,12112
CERTIFICATE
This is to certify that Cadet Ahad CBSE Roll No: 12129 has successfully
completed the project Work entitled Fitness Centre in the subject Computer Science
(083) laid down in the regulations of CBSE for the purpose of Practical
Examination in Class XII to be held in RPVV IP Extnension Patparganj Delhi -92
(Mr.Akant Sharma)
PGT Comp Science
Signature of External Examiner
Name: _______________________
Examiner Number:_______________
ACKNOWLEDGEMENT
Apart from the efforts of me, the success of any project depends largely on
the encouragement and guidelines of many others. I take this opportunity to express
my gratitude to the people who have been instrumental in the successful completion
of this project.
I express my heartfelt gratitude to my parents for constant encouragement
while carrying out this project.
I gratefully acknowledge the contribution of the individuals who contributed in
bringing this project up to this level, who continues to look after me despite my flaws,
I express my deep sense of gratitude to the luminary The Principal, RPVV IP
Extension Delhi-92 who has been continuously motivating and extending their
helping hand to us.
My sincere thanks to Mr. Akant Sharma, Master In-charge, A guide, A Mentor
, who critically reviewed my project and helped in solving each and every problem,
occurred during implementation of the project
The guidance and support received from all the members who
contributed and who are contributing to this project, was vital for the success
of the project. I am grateful for their constant support and help.
CONTENTS
1) Introduction
2) System Requirements
3) Source code
4) Output
5) Bibliography
INTRODUCTION
SYSTEM REQUIREMENTS
1.Processor : Intel i3 11thgen @3.11Ghz
2.Disk Space : 512 GB
3.Operating System : WIN 10
4.Python Version : 3.13
5.Mysql Version : 8.0.40
SOURCE CODE
1. import csv
2. from tabulate import tabulate
3. import mysql.connector as myc
4.
5. db=myc.connect(host="localhost", user="root",
passwd="ahad123@#",database="library")
6. cursor=db.cursor()
7. def add_book(a,b,c):
8. d=(a,b,c)
9. q = "insert into books(`Book name`,ID,Author) values(%s,%s,%s)"
10. cursor.execute(q, d)
11. print('The book has been added')
12. def del_book(a):
13. d=(a,)
14. q="delete from books where ID=%s"
15. cursor.execute(q,d)
16. print('The book has been deleted')
17. print()
18. print()
19. f=open("sheet1.csv",encoding='utf8')
20. r=csv.reader(f)
21. next(r)
22. l=[]
23. for i in r:
24. l.append(tuple(i))
25.
26. p=open('students.csv',encoding='utf8')
27. q=csv.reader(p)
28. next(q)
29. t=[]
30. for g in q:
31. t.append(tuple(g))
32.
33. cursor.execute("use library")
34. cursor.execute("create table books(`S.no` int primary key auto_increment,`Book
name` varchar(200),ID int,Author varchar(100),Issued varchar(20) default 'NO',ITW
varchar(100) default 'NULL')")
35. cursor.execute("create table students(name varchar(50),SID bigint,class
varchar(10),password varchar(40) default 'NULL',section varchar(3),IBN
varchar(100) default 'NULL')")
36. cursor.execute("create table rqst(s_name varchar(30),class varchar(10),section
varchar(3),b_name varchar(100),request varchar(100))")
37. q="insert into books(`Book name`,ID,Author) values(%s,%s,%s)"
38. for j in l:
39. cursor.execute(q,j)
40.
41.
42. q1="insert into students(name,SID,class,section) values (%s,%s,%s,%s)"
43. for e in t:
44. cursor.execute(q1,e)
45.
46. print(" ************Library Management System*****************")
47. print("________________________________________________________________
___________________________")
48. while True:
49. print('''
50. | Choose your role |
51.
52. 1.Librarian 2.Student
53.
54. ''')
55. i1=int(input("Enter the Number Which Belongs To You: "))
56. if i1==1:
57. i2=input("Enter The Password:")
58. if i2=="kalpana":
59. print()
60. print("-------Successfully Logged In-------")
61. print()
62. print("Welcome Kalpana Mam,What You want to do")
63. while True:
64. print('''
65. 1.Search Book 4.Students Section
66. 2.Add Book 5.Issue or Return request
67. 3.Delete Book 6.All Books
68. ''')
69. i1=int(input("Enter the Number Which Belongs To You: "))
70. if i1==1:
71. name=input("Do you want to Search Book by name or ID:")
72. name=name.lower()
73. if name=="name":
74. b_name=input("Enter the Book Name:")
75. e=(b_name,)
76. q1="select * from books where `Book Name`=%s"
77. cursor.execute(q1,e)
78. c=cursor.fetchall()
79. for i in c:
80. if i[-2]=="NO":
81. print(f"The book '{i[1]}' is available to issue")
82. elif i[-2]=="YES":
83. print(f"The book '{i[1]}' is already issued")
84. if c == []:
85. print(f"There is no book with name '{b_name}' ")
86. elif name=="id":
87. b_ID=input("Enter the Book ID:")
88. e = (b_ID,)
89. q1 = "select * from books where ID=%s"
90. cursor.execute(q1, e)
91. c = cursor.fetchall()
92. for i in c:
93. if i[-2] == "NO":
94. print(f"The book '{i[1]}' is available to issue")
95. elif i[-2]=="YES":
96. print(f"The book '{i[1]}' is already issued")
97. if c==[]:
98. print(f"There is no book with id '{b_ID}' ")
99.
100. elif i1==2:
101. name=input("Enter the Book Name:")
102. id=input("Enter the Book ID:")
103. author=input("Enter the Book Author:")
104. add_book(name,id,author)
105. elif i1==3:
106. id=input("Enter the Id of the book:")
107. del_book(id)
108. elif i1==4:
109. print("welcome To Students Section")
110. print()
111. print('''
112. 1.Search Student
113. 2.More..
114. ''')
115. i=int(input("What do you choose: "))
116. if i==1:
117. print('''
118. 1.Search with student ID 2.Search with Student Name
119. ''')
120. i=int(input("Choose:"))
121. if i==1:
122. id=input("Enter the Student ID:")
123. ID=(id,)
124. q="select * from students where `SID`=%s"
125. cursor.execute(q,ID)
126. c=cursor.fetchall()
127. for j in c:
128. d=j[0]
129. print(f"The student with id '{id}' is '{d}'")
130.
131. elif i==2:
132. name = input("Enter the Student name:")
133. NAME = (name,)
134. q = "select * from students where name=%s"
135. cursor.execute(q, NAME)
136. c = cursor.fetchall()
137. for j in c:
138. d = j[0]
139. print(f"The student with name '{name}' is '{d}'")
140. elif i==2:
141. print('''
142. 1.See the list of students who have issued books 2.see the list
of student class wise
143. ''')
144. i=int(input("Enter your choice: "))
145. if i==1:
146. q="select students.name , books.`Book name` from students
cross join books where students.IBN=books.`Book name` "
147. cursor.execute(q)
148. c=cursor.fetchall()
149. for j in c:
150. print("Name issued book")
151. print(f"{j[0]} - {j[1]} ")
152.
153. if i==2:
154. class_s=input("Enter the Student class:")
155. section=input("Enter the Student section:")
156. d=(class_s,section)
157. q='select name from students where class=%s AND section=
%s'
158. cursor.execute(q,d)
159. c=cursor.fetchall()
160. print(f"{class_s} {section} Students ")
161. for j in c:
162. print(j[0])
163. elif i1==5:
164. cursor.execute("select * from rqst")
165. c=cursor.fetchall()
166. j = []
167. for i in c:
168. j.append(list(i))
169. header=["Student","Class","Section","Book name","Query"]
170. print(tabulate(j,headers=header,tablefmt="fancy_grid"))
171. inp=input("Student name you want to solve query: ")
172. tup=(inp,)
173. q="select request,b_name from rqst where s_name=%s"
174. cursor.execute(q,tup)
175. d=cursor.fetchall()
176. l=list(d[0])
177. if l[0]=="issue":
178. inp1=input("Do you want to issue :")
179. if inp1.lower()=="yes":
180. tup3=(inp,l[1])
181. q3="update books set ITW=%s where `Book name`=%s"
182.
183. cursor.execute(q3,tup3)
184. print("The book has been issued")
185. tup = (inp,)
186. q3 = "delete from rqst where s_name=%s "
187. cursor.execute(q3, tup)
188. elif inp1=="no":
189. tup=(inp,)
190. q3="delete from rqst where s_name=%s "
191. cursor.execute(q3,tup)
192. print("Rejected successfully")
193. elif l[0]=="return":
194. inp1 = input("Do you want to accept :")
195. if inp1 == "yes":
196. tup3 = (l[1],)
197. q3 = "update books set ITW='NULL' where `Book name`=
%s"
198. cursor.execute(q3, tup3)
199. print("The book has been accepted from student")
200. tup = (inp,)
201. q3 = "delete from rqst where s_name=%s "
202. cursor.execute(q3, tup)
203. elif inp1 == "no":
204. tup = (inp,)
205. q3 = "delete from rqst where s_name=%s "
206. cursor.execute(q3, tup)
207. print("Rejected successfully")
208.
209. elif i1==6:
210. cursor.execute("select * from books")
211. c = cursor.fetchall()
212. j = []
213. for i in c:
214. j.append(list((i[0], i[1], i[2], i[3])))
215. columns = ["S.no", 'Book name', 'Book code', 'Author']
216. print(tabulate(j, headers=columns, tablefmt="fancy_grid"))
217. elif i1==7:
218. db.commit()
219. break
220.
221.
222.
223.
224. elif i1==2:
225. while True:
226. print('''
227. 1.Register
228. 2.Login
229. ''')
230. i3=int(input("Enter the Number Which Belongs To You: "))
231. if i3==1:
232. Name_S=input("Enter your Name: ")
233. ID_S=input("Enter your Student ID: ")
234. Class_S=input("Enter your Class: ")
235. Section_S=input("Enter your Section: ")
236. Password_S=input("Enter your Password: ")
237. entry=(Name_S,ID_S,Class_S,Password_S,Section_S)
238. q="insert into students(name,SID,class,password,section) value(%s,
%s,%s,%s,%s)"
239. cursor.execute(q,entry)
240. print("Registered succesfully")
241. elif i3==2:
242. ID_S=int(input("Enter Your Student ID: "))
243. password_S=input("Enter Your Password: ")
244. entry=(ID_S,)
245. q="select * from students where SID=%s"
246. cursor.execute(q,entry)
247. c=cursor.fetchall()
248. for i in c:
249. if i[1]==ID_S and i[3]==password_S:
250. print("****Succesfully logged in****")
251. print()
252. print(f"welcome {i[0]}")
253. print()
254. while True:
255.
256. print('''
257. 1.search book 4.All books
258. 2.Issue book
259. 3.Return book
260. ''')
261. a=int(input("What you want to do:"))
262. if a==1:
263. name = input("Do you want to Search Book by name aor
ID:")
264. name = name.lower()
265. if name == "name":
266. b_name = input("Enter the Book Name:")
267. e = (b_name,)
268. q1 = "select * from books where `Book Name`=%s"
269. cursor.execute(q1, e)
270. c = cursor.fetchall()
271. for i in c:
272. if i[-2] == "NO":
273. print(f"The book '{i[1]}' is available to issue")
274. elif i[-2] == "YES":
275. print(f"The book '{i[1]}' is already issued")
276. if c == []:
277. print(f"There is no book with name '{b_name}' ")
278. elif name == "id":
279. b_ID = input("Enter the Book ID:")
280. e = (b_ID,)
281. q1 = "select * from books where ID=%s"
282. cursor.execute(q1, e)
283. c = cursor.fetchall()
284. for i in c:
285. if i[-2] == "NO":
286. print(f"The book '{i[1]}' is available to issue")
287. elif i[-2] == "YES":
288. print(f"The book '{i[1]}' is already issued")
289. if c == []:
290. print(f"There is no book with id '{b_ID}' ")
291. elif a==2:
292. code=int(input("Enter the Book Code You want to issue:"))
293. tup=(code,)
294. q="select `Book name`,Issued from books where ID=%s"
295. cursor.execute(q,tup)
296. c = cursor.fetchall()
297. for j in c:
298. if j[-1] == "NO":
299. print(f"Is the book is '{j[0]}' you ae looking for")
300. a=input("Yes or No")
301. if a.lower() == "yes":
302. tup=(i[0],i[2],i[4],j[0],'issue')
303. print(tup)
304. q="insert into rqst values(%s,%s,%s,%s,%s)"
305. cursor.execute(q,tup)
306. print(cursor.execute,"hi")
307. print("Request sent to the teacher")
308. elif a.lower() == "no":
309. print("Renter right book code")
310. if j[-1] == "Yes":
311. print("The book has been issued and can't be issued
now")
312.
313. elif a==3:
314. tup=(i[0],)
315. q="select `Book name`,ID,Author from books where
ITW=%s"
316. cursor.execute(q,tup)
317. c=cursor.fetchall()
318. h=[]
319. for k in c:
320. h.append(list((k[0],k[1],k[2])))
321. header=["Book name","ID","Author"]
322. print(tabulate(h, headers=header, tablefmt="fancy_grid"))
323. inp=input("Do you want to return this book:")
324. for k in l[0]:
325. j=k
326. if inp.lower()=="yes":
327. tup1=(i[0],i[2],i[4],j,"return")
328. q='insert into rqst values(%s,%s,%s,%s,%s)'
329. cursor.execute(q,tup1)
330. print("Request sent to the teacher")
331.
332. elif a==4:
333. cursor.execute("select * from books")
334. c = cursor.fetchall()
335. j = []
336. for i in c:
337. j.append(list((i[0], i[1], i[2], i[3])))
338. columns = ["S.no", 'Book name', 'Book code', 'Author']
339. print(tabulate(j, headers=columns, tablefmt="fancy_grid"))
340. elif a==5:
341. break
342. elif i[1]==ID_S and i[2]!=password_S:
343. print("wrong password")
344. elif i[1] != ID_S and i[2] == password_S:
345. print("Retype student ID")
346. else:
347. print("student not registered")
348. db.commit()
349. break
350.
351.
352. db.commit()
353. db.close()
OUTPUT
BIBLIOGRAPHY
Books :
Websites : https://www.youtube.com