-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
48 lines (47 loc) · 2.3 KB
/
Copy pathtest.py
File metadata and controls
48 lines (47 loc) · 2.3 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
import json
import random
D={}
an=input('do want to make another id(y/n):')
while an=='y':
print("\n CREATING UNIQUE ID FOR STUDENT") #PROGRAM TO REGISTER STUDENTS
print(" ==============================")
nam=input("\n\tEnter the name of student:") #INPUTTING STUDENT INFORMATION
father=input("\tEnter the Father's name:")
mother=input("\tEnter the Mother's name:")
dob=input("\tEnter the date of birth of student(dd/mm/yyyy):")
cls=int(input("\tEnter the class of student(1-12):")) #CHECKING ERRORS IN INPUT
if cls not in [1,2,3,4,5,6,7,8,9,10,11,12]:
print("\n\n\t\tYOU ENTERED INVALID INFORMATION PLEASE TRY AGAIN.......")
break
stream="nil"
if cls>10:
stream=input("Enter stream(BIO/CS):")
if stream not in ["CS","BIO",'cs','bio']:
print("\n\n\t\tYOU ENTERED INVALID INFORMATION PLEASE TRY AGAIN......")
break
gen=input("Enter Gender of student(M/F):")
if gen not in ["M","F",'m','f']:
print("\n\n\t\tYOU ENTERED INVALID INFORMATION PLEASE TRY AGAIN........")
break
SGSC="Fal"
if gen=="F" or gen=='f':
SGSCcon=input("Is the student a Single Girl Child(y/n):")
if SGSCcon=="y":
SGSC="True"
adi=eval(input("Enter the admission number:"))
UID=int(random.random()*(10**9)) #GENERATING 14 DIGIT UID
print("\nThe generated Unique ID of student is:",UID)
feestat="Pending"
dictionary={UID:{"Student Name":nam,"Gender":gen,"SGSC":SGSC,"Admission number":adi,"DOB":dob,"Class":cls,"Stream":stream,"Father's name":father,"Mother's name":mother,"Fee Status":feestat}}
D.update(dictionary)
print('\nThe given imformation is:\n\t')
print(json.dumps(dictionary,indent=1))
an=input('do want to make another id(y/n):')
table='class_1'
import mysql.connector as sql
mycon=sql.connect(host='localhost',user='root',passwd='7654321',database='kvsfee')
cursor=mycon.cursor()
st="insert into class_1(UNQUE_ID,STUDENT_NAME,GENDER,SGSC,ADMISSION_NO,DOB,CLASS,FATHERS_NAME,MOTHERS_NAME) VALUES({},'{}','{}','{}',{},'{}',{},'{}','{}')".format(UID,nam,gen,SGSC,adi,dob,cls,father,mother)
cursor.execute(st)
mycon.commit()
mycon.close()