def post(self): try: parser = reqparse.RequestParser() addAuthArgs(parser) parser.add_argument('email', type=str, help='Email address to create user') parser.add_argument('password', type=str, help='Password to create user') args = parser.parse_args() if authenticate(args)['status'] == 100: return {'error': 'Authentication Failed'} _userEmail = args['email'] _userPassword = args['password'] conn = mysql.connect() cursor = conn.cursor() cursor.callproc('spCreateUser',(_userEmail,_userPassword)) data = cursor.fetchall() if len(data) is 0: conn.commit() return {'StatusCode':'200','Message': 'User creation success'} else: return {'StatusCode':'1000','Message': str(data[0])} except Exception as e: return {'error': str(e)}
def post(self): try: parser = reqparse.RequestParser() addAuthArgs(parser) parser.add_argument('userId', type=str) parser.add_argument('gameId', type=str) args = parser.parse_args() if authenticate(args)['status'] == 100: return {'error': 'Authentication Failed'} return removeGame(args['userId'], args['gameId']) except Exception as e: return {'error': str(e)}
def get(self): try: parser = reqparse.RequestParser() addAuthArgs(parser) parser.add_argument('tableName', type=str) args = parser.parse_args() if authenticate(args)['status'] == 100: return {'error': 'Authentication Failed'} _tableName = args['tableName'] return getRows(_tableName, '*') except Exception as e: return {'error': str(e)}
def get(self): try: parser = reqparse.RequestParser() addAuthArgs(parser) parser.add_argument('whereNames', type=str) parser.add_argument('whereVals', type=str) parser.add_argument('numRows', type=str) args = parser.parse_args() if authenticate(args)['status'] == 100: return {'error': 'Authentication Failed'} del args['email'] del args['password'] out = getRandGames(args) return out except Exception as e: return {'error': str(e)}
def post(self): try: parser = reqparse.RequestParser() addAuthArgs(parser) parser.add_argument('name', type=str, help='Name of table') parser.add_argument('argnames', type=str, help='Names of Arguments') parser.add_argument('argtypes', type=str, help='Types of Arguments') args = parser.parse_args() if authenticate(args)['status'] == 100: return {'error': 'Authentication Failed'} _tableName = args['name'] _argNames = (args['argnames'] + ',mmr,record').split(',') _argTypes = (args['argtypes'] + ',int,varchar(20)').split(',') return createTable(_tableName, _argNames, _argTypes) except Exception as e: return {'error': str(e)}
def post(self): try: parser = reqparse.RequestParser() addAuthArgs(parser) parser.add_argument('name', type=str) parser.add_argument('argnames', type=str) parser.add_argument('argvals', type=str) args = parser.parse_args() if authenticate(args)['status'] == 100: return {'error': 'Authentication Failed'} _tableName = args['name'] _argNames = args['argnames'] _argVals = args['argvals'] return removeRow(_tableName, _argNames, _argVals) except Exception as e: return {'error': str(e)}
def get(self): try: parser = reqparse.RequestParser() addAuthArgs(parser) parser.add_argument('table1', type=str) parser.add_argument('table2', type=str) parser.add_argument('join1', type=str) parser.add_argument('join2', type=str) parser.add_argument('joinType', type=str) parser.add_argument('null', type=str) parser.add_argument('neg', type=str) parser.add_argument('whereNames', type=str) parser.add_argument('whereVals', type=str) parser.add_argument('offset', type=str) parser.add_argument('numRows', type=str) parser.add_argument('order', type=str) parser.add_argument('dir', type=str) args = parser.parse_args() if authenticate(args)['status'] == 100: return {'error': 'Authentication Failed'} _table1 = args['table1'] _table2 = args['table2'] _join1 = args['join1'] _join2 = args['join2'] _joinType = args['joinType'] _null = args['null'] _neg = args['neg'] _whereNames = args['whereNames'] _whereVals = args['whereVals'] _offset = args['offset'] _numRows = args['numRows'] _order = args['order'] _dir = args['dir'] return getJoinedRowsOrdered(_table1, _table2, _join1, _join2, _joinType, _null, _neg, _whereNames, _whereVals, _offset, _numRows, _order, _dir) except Exception as e: return {'error': str(e)}
def get(self): try: parser = reqparse.RequestParser() addAuthArgs(parser) parser.add_argument('tableName', type=str) parser.add_argument('offset', type=str) parser.add_argument('numRows', type=str) parser.add_argument('order', type=str) parser.add_argument('dir', type=str) args = parser.parse_args() if authenticate(args)['status'] == 100: return {'error': 'Authentication Failed'} _tableName = args['tableName'] _offset = args['offset'] _numRows = args['numRows'] _order = args['order'] _dir = args['dir'] return getRowsOrdered(_tableName, _offset, _numRows, _order, _dir) except Exception as e: return {'error': str(e)}