Пример #1
0
 def get(self, tablname):
     student_db = Connectdb('studentdb')
     stmt = "SELECT * FROM ece_3b_dsp"
     data = None
     res = student_db.select(stmt, data)
     getcolnames = "SELECT COLUMN_NAME FROM information_schema.columns WHERE TABLE_NAME='ece_3b_dsp';"
     cols = student_db.select(getcolnames, None)
     colnames = [x[0] for x in cols]
     res.insert(0, colnames)
     return {'database': res, 'message': 'success'}, 200
Пример #2
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
Пример #3
0
 def post(self):
     teacher_db = Connectdb('teacherdb')
     logincreds = request.get_json()
     usrname = logincreds['name']
     usrhash = logincreds['hash']
     stmtchk = "SELECT name FROM teachertabl WHERE name LIKE %s"
     chkusr = teacher_db.select(stmtchk, (usrname, ))
     try:
         if chkusr[0][0] == usrname:
             stmt = "SELECT hash FROM teachertabl WHERE name=%s"
             data = (usrname, )
             tablhash = teacher_db.select(stmt, data)
             if tablhash[0][0] == usrhash:
                 return {'success': True}, 200
             else:
                 return {'success': False}, 401
         else:
             return {'success': False}, 403
     except IndexError:
         return {'success': False}, 403
Пример #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