def search(): """[Adding new batch_time] Returns: [str]: [normal string] """ #Caling function to connecting database mydb = sql_connection() try: if request.method == "POST": StudentBatchData = request.get_json() StudentID = StudentBatchData["STUDENTID"] print(StudentBatchData) mycursor = mydb.cursor() mycursor.execute( "SELECT* FROM student_data_ineuron WHERE STUDENT_ID = {}". format(StudentID)) print("select* from student_data_ineuron where STUDENT_ID = {}". format(StudentID)) studentFullData = {"studentFullData": mycursor.fetchall()[0]} mycursor.close() mydb.close() except Exception as e: return str(e) return studentFullData
def add_batch_time(): """[Adding new batch_time] Returns: [str]: [normal string] """ #Caling function to connecting database mydb = sql_connection() try: if request.method == "POST": StudentBatchData = request.get_json() Time = StudentBatchData["TIME"] MONDAY = StudentBatchData["MONDAY"] TUESDAY = StudentBatchData["TUESDAY"] WEDNESDAY = StudentBatchData["WEDNESDAY"] THURSDAY = StudentBatchData["THURSDAY"] FRIDAY = StudentBatchData["FRIDAY"] print(StudentBatchData) mycursor = mydb.cursor() add_student_query = "INSERT INTO student_batch_time (BTIME, MONDAY,TUESDAY,WEDNESDAY,THRUSDAY,FRIDAY) VALUES (%s,%s,%s,%s,%s,%s)" add_student_data = (Time, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY) mycursor.execute(add_student_query, add_student_data) mydb.commit() mycursor.close() mydb.close() except Exception as e: return e return StudentBatchData
def add_student(): """[Adding new student on the the class] Returns: [str]: [added stundent name] """ #Caling function to connecting database mydb = sql_connection() try: if request.method == "POST": StudentData = request.get_json() StudentName = StudentData["NAME"] StudentId = StudentData["ID"] Batch = StudentData["BATCH"] Branch = StudentData['BRANCH'] print(StudentData) mycursor = mydb.cursor() add_student_query = "INSERT INTO student_data_ineuron (STUDENT_ID, STUDENT_NAME, BRANCH,BATCH) VALUES (%s, %s, %s, %s)" add_student_data = (StudentId, StudentName, Branch, Batch) mycursor.execute(add_student_query, add_student_data) mydb.commit() mycursor.close() #Adding Student_Id For marks updating mycursor = mydb.cursor() add_student_id_for_marks_query = "INSERT INTO student_id_marks (STUDENT_ID) VALUES (%s)" add_student_id_for_marks_data = (StudentId, ) mycursor.execute(add_student_id_for_marks_query, add_student_id_for_marks_data) mydb.commit() mycursor.close() mydb.close() except Exception as e: return e return StudentData
def student_name(): print("------------------------------------") """[finding all the student having perticular batch] Returns: [list]: [list of all the student name] """ #Caling function to connecting database mydb = sql_connection() try: if request.method == "POST": StudentData = request.get_json() StudentBATCH = StudentData["BATCH"] print(StudentData) mycursor = mydb.cursor() add_student_query = "SELECT STUDENT_NAME FROM student_data_ineuron WHERE BATCH = %s" add_student_data = (StudentBATCH, ) mycursor.execute(add_student_query, add_student_data) RetriveStudentName = {} NameList = [] for i in mycursor: NameList.append(i[0]) RetriveStudentName["NAME"] = NameList print(RetriveStudentName) mycursor.close() mydb.close() #SuccessReturn = (StudentName +" Is added into the system having ID = "+StudentId+" ,Brach = "+Branch+" and batch = "+Batch) except Exception as e: return e return RetriveStudentName