· 4 years ago · Mar 15, 2021, 10:14 AM
1STR = """
2\t\t\t\tCODING INFORMATIONS
3
4Group Members :
5
6 1. Manas Tiwari -- 12 M2 -- 02 ( Admin )
7 2. Zaid khan -- 12 M2 -- 05
8 3. Abhinav Srivastav -- 12 M2 -- 30
9 4. Arnav Agrahari -- 12 M2 -- 14
10 5. Yashdeep
11
12EDoc (Source Code) : https://pastebin.com/945Sy9Gh
13
141. This Project Is Completed Under the guidence of our computer teacher (Mr. K.C Bhargav).
152. The project Works for managing the fees records of students, it store the information(name, class, section
16roll number, Number of month fees is submitted).
173. The Sr number of the students will be automatically generated by the program in series.(By Counting number
18of records are saved in the sql table and than by adding 1 to it).
194. The Project Is Open Source Any One Cn Modify Any Thing Without Any Authorization . :)
205. This Project Is Discontinued By Maintainer
216. Final Version Is 0.001A
22
23Module Used :
24 Sql Connector - Comes Default After Installing Mysql In Developer or If Selected While Installing Mysql
25 Command For Installing : pip install mysql.connector-python or
26 pip3 install mysql.connector-python
27
28 Random - Comes Default By The Installation Of Python
29
30 Time - Comes Default By The Installation Of Python
31
32\t\t\t\tFEES MANAGEMENT SYSTEM - Help
33SQL CONNECTION STATUS - [CONNECTED]
34VERSION - [0.001A]
35DATABASE NAME - [Fees_Manager]
36SERVER - [SQL]
37TESTED ON - [Python 3.7.8 64 Bit\\Python 3.9 64 Bit & MYSQL 8.0]
38TESTED PLATFORMS - [WINDOWS, LINUX (UBUNTU 20.04 LTS)]
39
40Home Menu Instructions :
411. Add Student To Add Students Data In SQL Server ( All Update The Fee Record )
422. Deposit Fee ( Only Of Existing Student In Server Table) Updates The Fee Recoed UpTo 12 (Numbers Represent
43there respective months)
443. Used For Updting The Fees Of All The Classes Which Is Going to stored in Fee_Amount.txt
454. Filter Records (Present In SQL DATABASE TABLE) (On the basis of Name, Class, Sr Number, Class-Section
465. Is Used To Delete All The Tables And Records.
476. For HELP
487. For Ending The Program.
49
50
51Happy Coding :)
52
53"""
54
55import mysql.connector as sql
56from time import sleep
57import random
58
59
60print("VERSION - 0.001A")
61print("ESTABLISHING CONNECTIONS .....\n")
62sleep(1)
63
64def fee_amount():
65 """This function manages the Fee_Amount.txt file which contain fee amount of each and every class
66 if the fee_amount.txt file is not present in the folder, this function creates the file with default
67 fee amount.
68 """
69 with open("Fee_Amount.txt", "a") as f:
70 with open("Fee_Amount.txt", "r") as i:
71 if len(i.readlines()) == 0:
72 f.write("1 - 500\n")
73 f.write("2 - 700\n")
74 f.write("3 - 900\n")
75 f.write("4 - 1000\n")
76 f.write("5 - 1200\n")
77 f.write("6 - 1400\n")
78 f.write("7 - 1600\n")
79 f.write("8 - 1800\n")
80 f.write("9 - 2000\n")
81 f.write("10 - 2200\n")
82 f.write("11 - 2400\n")
83 f.write("12 - 2450\n")
84 elif len(i.readlines()) > 13 or len(i.readlines()) < 13:
85 with open("Fee_Amount.txt", "w") as f:
86 f.write("")
87 with open("Fee_Amount.txt", "a") as f:
88 f.write("1 - 500\n")
89 f.write("2 - 700\n")
90 f.write("3 - 900\n")
91 f.write("4 - 1000\n")
92 f.write("5 - 1200\n")
93 f.write("6 - 1400\n")
94 f.write("7 - 1600\n")
95 f.write("8 - 1800\n")
96 f.write("9 - 2000\n")
97 f.write("10 - 2200\n")
98 f.write("11 - 2400\n")
99 f.write("12 - 2450\n")
100
101fee_amount() # Managing The Fee_Amount.txt
102
103passwd = "manas123" # MYSQL PASSWORD
104
105# In the next upcoming line the program is going to try to connect the python with mysql server
106mycon = sql.connect(host='localhost',
107 user='root',
108 passwd=passwd)
109
110mycursor = mycon.cursor()
111print("Checking For database... \n") # 2nd > Just A print statement to increase the number of lines :)
112sleep(1)
113
114#! In the next upcoming line the program is going to create a database in sql server named Fees_Manager (If not exists)
115mycursor.execute("CREATE DATABASE IF NOT EXISTS Fees_Manager")
116
117print("Creating Database If Not Exist... Done!\n") #3rd > another print statement
118sleep(1) # sleep Statement
119
120#! In the next upcoming line the program is going to Use the previously created database (fees_manager)
121mycursor.execute("USE Fees_Manager")
122
123#!In the next upcoming line the program is going to create a table named students which is going to contain
124#!all the information related to fee, the table contain SR NUMBER, NAME, CLASS, SECTIOn, ROLL_No, sub.Fee Month
125mycursor.execute(
126 "CREATE TABLE IF NOT EXISTS students(SR int, Name varchar(255), Class varchar(15), Section varchar(15), Roll_No int, Submitted int)")
127
128#! In the next upcoming line the program is going to check is the connection to sql is established or not
129if mycon.is_connected():
130 print("Connecting To Database ...\n") #4 Print statement
131 sleep(1)
132 print("Successfully Connected\n")# 5 print
133 print() # 6 print
134
135
136def sleepRan():
137 num = random.choice([0, 0.11, 0.0001, 0.21, 0.00000009, 0.5, 0.4, 0.004, 0.44, 0.00000001])
138 sleep(num)
139 return num
140
141
142def add_student(Name, Class, Section, Roll_No):
143 """This function adds student data to the mysql table which contains all the data that are specified
144 above.
145
146 Args:
147 Name (String): Name of the student
148 Class (integer): Class of the student
149 Section (string): Section of the students class
150 Roll_No (integer): roll number of the specified student
151 """
152 CMD = f"SELECT * FROM students"
153 data = mycursor.execute(CMD)
154 records = mycursor.fetchall()
155 Sr = len(records) + 1
156
157 Month = 0
158 while Month <= 0:
159 Month = int(
160 input("Enter Number Of Month Fee You Want To Submit 0 < x <=12 >>> "))
161 if Month > 12:
162 print("Invalid Month Number!\n")
163 Month = 0
164 print("Re-Enter Number Of Month")
165 if Month < 0:
166 print("Invalid Month Number!\n")
167 Month = 0
168 print("Re-Enter Number Of Month")
169
170 with open("Fee_Amount.txt", "r") as f:
171 data = f.readlines()
172 amt = data[int(Class)-1].replace("\n", "").split(" - ")
173 amt = int(amt[1])
174 print("\nEach Month Fee : ", amt)
175 print()
176 amt = Month*amt
177
178 print(f"\nTotal Fee Amount : {amt}\n")
179 print("\nBefore You Save Take A Look To Entered Information : \n")
180 print("-"*10, "SUMMARY INFO", "-"*10)
181 print("\n")
182 print("SR Number : ", Sr, " Allotted ".upper())
183 print("Name : ", Name)
184 print("Class : ", Class)
185 print("Section : ", Section)
186 print("Roll No : ", Roll_No)
187 print("Number Of Month Fee Submitted : ", Month)
188 print()
189 print("-"*25)
190 print()
191 yn = input("Sure To Save This Record (Yes/No) >>> ")
192 yn = yn.lower()
193 if 'y' in yn:
194 value = 'INSERT INTO students values(%s,%s,%s,%s,%s,%s)'
195 values = [(Sr, Name, Class, Section, Roll_No, Month)]
196 mycursor.executemany(value, values)
197 mycon.commit()
198 print("\nSaving Student Data...\n")
199 sleep(1)
200 print("Data Saved!\n")
201 else:
202 print("Quiting ... ")
203
204
205def change_fee():
206 """This function is used for changing the fee amount.
207 """
208 Class = 1
209 with open("Fee_Amount.txt", "w") as f:
210 f.write("")
211 while Class != 13:
212 Amount = int(input(f"Enter Fee Amount For Class {Class} >>> "))
213 if Amount < 0:
214 continue
215 with open("Fee_Amount.txt", "a") as f:
216 f.write(f"{Class} - {Amount}\n")
217 Class += 1
218
219
220def Filter_By_Sr(SR):
221 """This function prints table of students stored data of specified SR number
222
223 Args:
224 SR (int): Sr number of the student
225 """
226 CMD = f"SELECT * FROM students WHERE SR = {SR}"
227 data = mycursor.execute(CMD)
228 records = mycursor.fetchall()
229 # Sr, Name, Class, Section, Roll_No, Month
230 Name = records[0][1]
231 Class = records[0][2]
232 Section = records[0][3]
233 Roll = records[0][4]
234 fee_submitted = records[0][5]
235 total = len(records)
236 print("-"*75)
237 print ("{:<8} {:<15} {:<10} {:<10} {:<10} {:<10}".format('SR No.','Name','Class','Section', 'Roll No.', 'Submitted Record'))
238 print("-"*75)
239 print()
240 Sum = 0
241 print ("{:<8} {:<15} {:<10} {:<10} {:<10} {:<10}".format(SR, Name, Class, Section, Roll, fee_submitted))
242 Sum += sleepRan()
243 print()
244 print("-"*75)
245 print(f"\nTotal Rows : {total}\n")
246 print(f"{total} Rows in {Sum} Sec(s)")
247
248
249def Filter_By_Name(Name):
250 """This function finds every match of specified name and prints the table which contain all the data
251
252 Args:
253 Name (str): NAME OF STUDENT
254 """
255 CMD = f"SELECT * FROM students WHERE Name = '{Name}'"
256 data = mycursor.execute(CMD)
257 records = mycursor.fetchall()
258 total = len(records)
259 print()
260 print("-"*75)
261 print ("{:<8} {:<15} {:<10} {:<10} {:<10} {:<10}".format('|SR No.','|Name','|Class','|Section', '|Roll No.', '|Submitted Record'))
262 print("-"*75)
263 print()
264 Sum = 0
265 for i in records:
266 print ("{:<8} {:<15} {:<10} {:<10} {:<10} {:<10}".format("|"+str(i[0]), "|"+str(i[1]), "|"+str(i[2]), "|"+str(i[3]), "|"+str(i[4]), "|"+str(i[5])))
267 Sum += sleepRan()
268 print("-"*75)
269 print(f"\nTotal Rows : {total}\n")
270 print(f"{total} Rows in {Sum} Sec(s)")
271
272
273def Filter_By_Class(Class):
274 """This function finds every match of specified Class and prints the table which contain all the data
275
276 Args:
277 Class (int): Class of the student.SECTION IS NOT INCLUDED
278 """
279 CMD = f"SELECT * FROM students WHERE Class = '{Class}'"
280 data = mycursor.execute(CMD)
281 records = mycursor.fetchall()
282 total = len(records)
283 print()
284 print("-"*75)
285 print ("{:<8} {:<15} {:<10} {:<10} {:<10} {:<10}".format('|SR No.','|Name','|Class','|Section', '|Roll No.', '|Submitted Record'))
286 print("-"*75)
287 print()
288 Sum = 0
289 for i in records:
290 print ("{:<8} {:<15} {:<10} {:<10} {:<10} {:<10}".format("|"+str(i[0]), "|"+str(i[1]), "|"+str(i[2]), "|"+str(i[3]), "|"+str(i[4]), "|"+str(i[5])))
291 Sum += sleepRan()
292 print("-"*75)
293 print(f"\nTotal Rows : {total}\n")
294 print(f"{total} Rows in {Sum} Sec(s)")
295
296
297def Filter_By_Section(Class_Sec):
298 """This function finds every match of specified Class-Section and prints the table which contain all the data
299
300 Args:
301 Class_Sec (str): Class and section of student, format = class-section
302 """
303 Class = Class_Sec.split("-")
304 CMD = f"SELECT * FROM students WHERE Class = '{Class[0]}' AND Section = '{Class[1]}'"
305 data = mycursor.execute(CMD)
306 records = mycursor.fetchall()
307 total = len(records)
308 print()
309 print("-"*75)
310 print ("{:<8} {:<15} {:<10} {:<10} {:<10} {:<10}".format('|SR No.','|Name','|Class','|Section', '|Roll No.', '|Submitted Record'))
311 print("-"*75)
312 print()
313 Sum = 0
314 for i in records:
315 print ("{:<8} {:<15} {:<10} {:<10} {:<10} {:<10}".format("|"+str(i[0]), "|"+str(i[1]), "|"+str(i[2]), "|"+str(i[3]), "|"+str(i[4]), "|"+str(i[5])))
316 Sum += sleepRan()
317 print("-"*75)
318 print(f"\nTotal Rows : {total}\n")
319 print(f"{total} Rows in {Sum} Sec(s)")
320
321def deposit_fee(Sr):
322 """This function updates ONLY FEE record of the student when fee of the student is submitted
323
324 Args:
325 Sr (int): SR number of the student
326 """
327 CMD = f"select * from students where SR={Sr}"
328 data = mycursor.execute(CMD)
329 records = mycursor.fetchall()
330 Name = records[0][1]
331 Class = records[0][2]
332 Section = records[0][3]
333 Roll = records[0][4]
334 fee_submitted = records[0][5]
335 print()
336 print("-"*26, " Info ", "-"*26)
337 print("Sr Number : ", Sr)
338 print("Student Name : ", Name)
339 print("Class : ", Class)
340 print("Section : ", Section)
341 print("Roll Number ", Roll)
342 print("Month Fee Left : ", 12-int(fee_submitted))
343 print("-"*65)
344 print()
345 if 12-int(fee_submitted) != 0:
346 Month = 0
347 if 12-int(fee_submitted) != 1:
348 while Month == 0:
349 Month = int(input(
350 f"Enter Number Of Month Fee You Want To Submit 0 < x <={12-int(fee_submitted)} >>> "))
351 if Month > 12-int(fee_submitted):
352 print("\nInvalid Month Number!\n")
353 Month = 0
354 print("\nRe-Enter Number Of Month")
355 if Month < 0:
356 print("\nInvalid Month Number!\n")
357 Month = 0
358 print("\nRe-Enter Number Of Month")
359 else:
360 Month = 1
361 with open("Fee_Amount.txt", "r") as f:
362 data = f.readlines()
363 amt = data[int(Class)-1].replace("\n", "").split(" - ")
364 amt = int(amt[1])
365 print("\nEach Month Fee : ", amt)
366 amt = Month*amt
367 print(f"\nFee Amount : {amt}")
368 yn = input("\nSure To Save This Record (yes/No) >>> ")
369 print()
370 yn.lower()
371 submitted = int(fee_submitted) + Month
372 if 'y' in yn:
373 CMD = f"UPDATE students SET Submitted={submitted} WHERE SR={Sr}"
374 mycursor.execute(CMD)
375 mycon.commit()
376 else:
377 print("\n12 Month Fees Is Already Submitted!\n")
378
379
380
381while True:
382 try:
383 print("-"*75)
384 print("\t\t\t\tFEES MANAGEMENT SYSTEM")
385 print("-"*75)
386 print()
387 print("SQL CONNECTION STATUS - [CONNECTED]\n")
388 print("VERSION - [0.001A]\n")
389 print("DATABASE NAME - [Fees_Manager]\n")
390 print("SERVER - [SQL]\n")
391 print("TESTED ON - [Python 3.7.8 64 Bit\\Python 3.9 64 Bit & MYSQL 8.0]\n")
392 print("TESTED PLATFORMS - [WINDOWS, LINUX (UBUNTU 20.04 LTS)]")
393 print("-"*75)
394 print("\n1. Add Student\n2. Deposit Fee\n3. Change Fee\n4. Filter Students Data \n5. Delete Record\n6. Help\n7. Exit")
395 user = int(input("\nEnter Your Choice (Natural Numbers Only) >>> "))
396
397 if user == 1:
398 print("\n"*30)
399 Sr = 0
400 Name = input("\nEnter Student Name >>> ").title()
401 Class = int(input("\nEnter Class >>> "))
402 if Class > 12:
403 print("Invalid Class!\n")
404 if Class < 0:
405 print("Invalid Class!\n")
406 Section = input("\nEnter Section >>> ").title()
407 Roll_No = int(input("\nEnter Roll Number >>> "))
408 print("Checking Info...\n")
409 add_student(Name, Class, Section, Roll_No)
410
411 elif user == 2:
412 Sr = 0
413 print("\n"*30)
414 while Sr == 0:
415 Sr = int(input("\nEnter Sr Number >>> "))
416 if Sr < 0:
417 print("\nInvalid Sr Number .\n")
418 Sr = 0
419 deposit_fee(Sr)
420
421 elif user == 3:
422 print("\n"*30)
423 change_fee()
424
425 elif user == 4:
426 print()
427 print(" 1.By Name\n\
428 2.By Sr Number\n\
429 3.By Class\n\
430 4.By Class And Section")
431 choose = int(input("\nChoose Your Operation UpTo 4 (Natural Numbers <= 4),Exit ? Press 0 >>> "))
432 if choose >= 0:
433 if choose == 0:
434 print("\nReturning To Home ....\n")
435 elif choose == 1:
436 name = input("\nEnter Name, 0 To Exit >>> ")
437 if name != "" and name != "0":
438 print("\n"*30)
439 Filter_By_Name(name)
440 elif choose == 2:
441 Sr = 0
442 while Sr == 0:
443 Sr = int(input("\nEnter Sr Number, 0 Exit >>> "))
444 if Sr < 0:
445 print("\nInvalid Sr Number .\n")
446 Sr = 0
447 if Sr != 0:
448 print("\n"*30)
449 Filter_By_Sr(Sr)
450 elif choose == 3:
451 Class = 0
452 while Class == 0:
453 Class = int(input("\nEnter Class, 0 Exit >>> "))
454 if Class < 0:
455 print("\nInvalid Class .\n")
456 Class = 0
457 if Class != 0:
458 print("\n"*30)
459 Filter_By_Class(Class)
460 elif choose == 4:
461 Class_Sec = input("\nEnter Class-Section, 0 To Exit >>> ")
462 if Class_Sec != "" and Class_Sec != "0":
463 print("\n"*30)
464 Filter_By_Section(Class_Sec)
465 else:
466 print("\nReturning To Home ....\n")
467
468 elif user == 5:
469 print("\n"*30)
470 yn = input("\nAre You Sure To Delete All Stored Records (Yes/No)>>> ").lower()
471 if 'y' in yn:
472 print("\nDeleting Data Total Steps : 2 Done : 0\\2 ... ")
473 with open("Fee_Amount.txt", "w") as f:
474 f.write("")
475 sleep(0.04)
476 print("\nDeleted (1/2) !")
477 CMD = "DROP DATABASE Fees_Manager"
478 mycursor.execute(CMD)
479 sleep(1)
480 print("\nDeleted (2/2) !")
481 print("\nALL RECORDS ARE DELETED SUCCESSFULLY!\n")
482 print("\nProcessing (1/4) ....")
483 sleep(1)
484 mycursor.execute("CREATE DATABASE IF NOT EXISTS Fees_Manager")
485 print("\nProcessing (2/4) ....")
486 sleep(1)
487 mycursor.execute("USE Fees_Manager")
488 print("\nProcessing (3/4) ....")
489 sleep(1)
490 mycursor.execute(
491 "CREATE TABLE IF NOT EXISTS students(SR int, Name varchar(255), Class varchar(15), Section varchar(15), Roll_No int, Submitted int)")
492 print("\nProcessing (4/4) ....")
493 fee_amount()
494 sleep(1)
495 print("\nProcessing Done !\n")
496 else:
497 print("\nExiting From This Step ...\n")
498
499 elif user == 6:
500 print("\n"*9)
501 print("Click Squeezed Text (xx Lines) To Display Help")
502 print(STR)
503
504 elif user == 7:
505 print("\n"*30)
506 yn = input("\nAre You Sure To Exit (Yes/No)>>> ")
507 if yn[0] == "y":
508 print("\nThank You For Using !")
509 print("Exiting .... ")
510 sleep(2)
511 break
512 else:
513 print("\nReturning To Home ....")
514 else:
515 print("Invalid Option!\n")
516 input("\nPRESS ENTER TO CONTINUE >>> ")
517 print("\n"*40)
518
519 except Exception as e:
520 print("\n"*30)
521 print("Some Error! (", e, ")")
522 input("\nPRESS ENTER TO CONTINUE >>> ")
523 print("\n"*30)
524
525print("VERSION 0.001A")
526