Пример #1
0
 def put(self, date):
     student_db = Connectdb('studentdb')
     stmt = "SHOW COLUMNS FROM ece_3b_dsp like '" + date + "'"
     res = student_db.select(stmt, None)
     if len(res) == 0:
         return {'message': 'This class does not exist!'}, 404
     else:
         stmt2 = "ALTER TABLE ece_3b_dsp DROP COLUMN `" + date + "`"
         res2 = student_db.change(stmt2, None)
         return {'message': res2}, 200
Пример #2
0
 def post(self):
     teacher_db = Connectdb('teacherdb')
     registercreds = request.get_json()
     usrname = registercreds['name']
     usrhash = registercreds['hash']
     print(usrname, usrhash)
     stmt = "INSERT INTO teachertabl (name, hash) VALUES (%s, %s)"
     data = (usrname, usrhash, )
     res = teacher_db.change(stmt, data)
     return {'message': res}, 201
Пример #3
0
 def post(self):
     response = request.get_json()
     attendancedb = Connectdb('studentdb')
     roll_no = response['roll_no']
     name = response['name']
     univ_roll_no = response['univ_roll_no']
     reg_no = response['reg_no']
     stmt = "INSERT INTO ece_3b_dsp (roll_no, univ_roll_no, reg_no, name) VALUES (%s, %s, %s, %s)"
     data = (roll_no, univ_roll_no, reg_no, name, )
     res = attendancedb.change(stmt, data)
     print(res)
     return {'message': res}, 201
Пример #4
0
 def put(self, publichash, roll_no, date):
     with open('auth.json') as authjson:
         jsondata = json.load(authjson)
         privatehash = jsondata['token']
         authjson.close()
     if privatehash == publichash:
         attendancedb = Connectdb('studentdb')
         stmtchk = "SELECT `" + date + "` FROM ece_3b_dsp WHERE roll_no=%s"
         datachk = (roll_no, )
         reschk = attendancedb.select(stmtchk, datachk)
         if reschk[0][0] == None:
             stmt = "UPDATE ece_3b_dsp SET `" + date + "` =1 WHERE roll_no=%s"
             data = (roll_no, )
             res = attendancedb.change(stmt, data)
             print(res)
             return {'message': res, 'code': 201}, 201
         else:
             return {'message': 'You got your attendance already!'}, 400
     else:
         return {'message': 'Hash mismatch! Dont try to copy QRs ;)'}, 404
Пример #5
0
 def put(self, date):
     student_db = Connectdb('studentdb')
     stmt = "ALTER TABLE ece_3b_dsp ADD COLUMN `" + date + "` TINYINT(1) NULL"
     data = None
     res = student_db.change(stmt, data)
     return {'message': res}, 201