Esempio n. 1
0
def get_neighbourhoods_where_all_car_stolen():
    client = get_mysql_client()
    try:
        result = client.select_neighbourhoods_where_all_car_stolen()
        return jsonify(result)
    except PerpException as e:
        return error_to_json(e), 400
Esempio n. 2
0
def delete_criminal(criminal_id):
    client = get_mysql_client()
    try:
        result = client.delete_criminal(criminal_id)
        return jsonify(result)
    except PerpException as e:
        return error_to_json(e), 400
Esempio n. 3
0
def get_total_value_of_thefts():
    client = get_mysql_client()
    try:
        result = client.select_total_value_of_thefts()
        return jsonify(result)
    except PerpException as e:
        return error_to_json(e), 400
Esempio n. 4
0
def get_crimes_count():
    client = get_mysql_client()
    try:
        result = client.select_crime_count_by_month(
            request.args.get("month_from"), request.args.get("month_to"))
        return jsonify(result)
    except PerpException as e:
        return error_to_json(e), 400
Esempio n. 5
0
def get_column_from_criminal(column_name):
    client = get_mysql_client()
    try:
        result = client.select_column_from_criminal(
            column_name, request.args.get("page"),
            request.args.get("page_size"))
        return jsonify(result)
    except PerpException as e:
        return error_to_json(e), 400
Esempio n. 6
0
def get_all_from_table(table_name):
    client = get_mysql_client()
    try:
        result = client.select_all_from_table(table_name,
                                              request.args.get("order"),
                                              request.args.get("num_rows"),
                                              request.args.get("page"),
                                              request.args.get("page_size"))
        return jsonify(result)
    except PerpException as e:
        return error_to_json(e), 400
Esempio n. 7
0
def post_criminal():
    client = get_mysql_client()
    try:
        result = client.insert_new_criminal(
            request.args.get("age"),
            request.args.get("height_cm"),
            request.args.get("hair_color"),
            request.args.get("lives_in"),
        )
        return jsonify(result)
    except PerpException as e:
        return error_to_json(e), 400
Esempio n. 8
0
def patch_criminal(criminal_id):
    client = get_mysql_client()
    try:
        result = client.update_criminal(
            criminal_id,
            request.args.get("age"),
            request.args.get("height_cm"),
            request.args.get("hair_color"),
            request.args.get("lives_in"),
        )
        return jsonify(result)
    except PerpException as e:
        return error_to_json(e), 400