Ejemplo n.º 1
0
 def delete(self, user_id):
     delete_user = "******"
     delete_statement = delete_user.format(user_id)
     try:
         query_db(delete_statement, connected)
         return "", 204
     except Exception as e:
         return "An Error Occured:{}".format(e), 400
Ejemplo n.º 2
0
 def delete(self, item_id):
     delete_item = "DELETE FROM `Item` WHERE `id` = {}"
     delete_statement = delete_item.format(item_id)
     try:
         query_db(delete_statement, connected)
         return "", 204
     except Exception as e:
         return "An Error Occured:{}".format(e)
Ejemplo n.º 3
0
 def get(
     self
 ):  #Currently all booleans return 0 or 1, not sure if this will be an issue
     parser = reqparse.RequestParser()
     parser.add_argument(
         'item', type=str)  #Returns a specific user by specified by id
     args = parser.parse_args()
     if args["item"]:
         select_statement = "SELECT * FROM Item WHERE `id` = {}".format(
             args["item"])
         return query_db(select_statement, connected)
     select_statement = "SELECT * FROM Item"
     return query_db(select_statement, connected), 200
Ejemplo n.º 4
0
 def get(self):
     parser = reqparse.RequestParser()
     parser.add_argument(
         'id', type=int)  #Returns a specific user by specified by id
     parser.add_argument('user',
                         type=str)  #Returns a specific user by user_name
     args = parser.parse_args()
     if args["id"]:
         select_statement = "SELECT * FROM User WHERE `id` = {}".format(
             args["id"])
         return query_db(select_statement, connected)
     if args["user"]:
         select_statement = "SELECT * FROM User WHERE `user_name` = {}".format(
             args["user"])
         return query_db(select_statement, connected)
     select_statement = "SELECT * FROM User"
     return query_db(select_statement, connected), 200
Ejemplo n.º 5
0
    def put(self, user_id):
        update_users = "UPDATE `User` SET `user_name` = '{}', `password` = '{}' WHERE `id` = {}"
        try:
            name = request.json["user_name"]
            user_pass = request.json["password"]
        except KeyError as e:
            return "No Key provided for:{}".format(e), 400

        update_statement = update_users.format(name, user_pass, user_id)
        return query_db(update_statement, connected), 204
Ejemplo n.º 6
0
    def post(self):  #Need to look into hashing passwords using pbkdf2_hmac
        insert_users = "INSERT INTO `User` (`user_name`,`password`) VALUES ('{}', '{}')"

        try:
            name = request.json["user_name"]
            user_pass = request.json["password"]
        except KeyError as e:
            return "No Key provided for:{}".format(e), 400

        insert_statement = insert_users.format(name, user_pass)
        return query_db(insert_statement, connected), 201
Ejemplo n.º 7
0
    def put(self, item_id):
        update_item = "UPDATE `Item` SET `item_name` = '{}', `price` = {}, `quantity` = {}, `status` = '{}', `instock` = {},`src` = '{}', `sell` = {}, `rent` = {} WHERE `id` = {}"
        try:
            name = request.json["item_name"]
            price = request.json["price"]
            quantity = request.json["quantity"]
            status = request.json["status"]
            instock = request.json["instock"]
            src = request.json["src"]
            sell = request.json["sell"]
            rent = request.json["rent"]
        except KeyError as e:
            return "No Key provided for:{}".format(e), 400

        update_statement = update_item.format(name, price, quantity, status,
                                              instock, src, sell, rent,
                                              item_id)
        return query_db(update_statement, connected), 204
Ejemplo n.º 8
0
    def post(self):
        insert_items = "INSERT INTO `Item` (`item_name`,`price`,`quantity`,`status`,`instock`,`src`,`sell`,`rent`) VALUES ('{}', {}, {}, '{}', {},'{}', {}, {})"

        try:
            name = request.json["item_name"]
            price = request.json["price"]
            quantity = request.json["quantity"]
            status = request.json["status"]
            instock = request.json["instock"]
            src = request.json["src"]
            sell = request.json["sell"]
            rent = request.json["rent"]
        except KeyError as e:
            return "No Key provided for:{}".format(e), 400

        insert_statement = insert_items.format(name, price, quantity, status,
                                               instock, src, sell, rent)
        return query_db(insert_statement, connected), 201