Ejemplo n.º 1
0
def init_database_sec_diff_local():
    try:
        connect = sqlite3.connect('./resources/diff.db')
        cursor = connect.cursor()

        sql_create_sec_diff = "create table if not exists sec_diff (type_name text,diff text);"
        cursor.execute(sql_create_sec_diff)
        with open('./resources/diff.csv', 'r') as f:
            list_tmp = f.readlines()

        list_real_data = [
            item.replace("\n", "").split(",") for item in list_tmp
        ]
        del list_tmp
        db_insert_diff(list_real_data, cursor)
        del list_real_data
        cursor.close()
        connect.commit()
        connect.close()
        return jsonify({
            "status": "successful",
            "content": "Database initialization succeeded",
            "function": "init_database_sec_diff_local"
        }), 200
    except Exception as err:
        list_tmp = exceptionHandler(err)
        return jsonify(list_tmp[0]), list_tmp[1]
Ejemplo n.º 2
0
def database_sec_diff_insert():
    try:
        connect = sqlite3.connect('./resources/diff.db')
        cursor = connect.cursor()
        db_insert_diff(request.json['data'], cursor, True)
        connect.commit()
        connect.close()
        return jsonify({
            "status": "successful",
            "content": "Data insertion successful",
            "function": "database_sec_diff_insert"
        }), 200
    except Exception as err:
        list_tmp = exceptionHandler(err)
        return jsonify(list_tmp[0]), list_tmp[1]
Ejemplo n.º 3
0
def database_sec_diff_insert(request_json: RequestJSON):
    try:
        connect = sqlite3.connect('./resources/diff.db')
        cursor = connect.cursor()
        db_insert_diff(request_json.data, cursor, True)
        connect.commit()
        connect.close()
        return JSONResponse(status_code=200,
                            content={
                                "status": "successful",
                                "content": "Data insertion successful",
                                "function": "database_sec_diff_insert"
                            })
    except Exception as err:
        list_tmp = exceptionHandler(err)
        return JSONResponse(status_code=list_tmp[1], content=(list_tmp[0]))
Ejemplo n.º 4
0
def init_database_sec_diff():
    try:
        connect = sqlite3.connect('./resources/diff.db')
        cursor = connect.cursor()
        sql_create_sec_diff = "create table if not exists sec_diff (type_name text,diff text);"
        cursor.execute(sql_create_sec_diff)
        db_insert_diff(request.json['data'], cursor)
        cursor.close()
        connect.commit()
        connect.close()
        return jsonify({
            "status": "successful",
            "content": "Database initialization succeeded",
            "function": "init_database_sec_diff"
        }), 200
    except Exception as err:
        list_tmp = exceptionHandler(err)
        return jsonify(list_tmp[0]), list_tmp[1]
Ejemplo n.º 5
0
def init_database_sec_diff(request_json: RequestJSON):
    try:
        connect = sqlite3.connect('./resources/diff.db')
        cursor = connect.cursor()
        cursor.execute(
            "create table if not exists sec_diff (type_name text,diff text);")
        db_insert_diff(request_json.data, cursor)
        cursor.close()
        connect.commit()
        connect.close()
        return JSONResponse(status_code=200,
                            content=({
                                "status": "successful",
                                "content": "Database initialization succeeded",
                                "function": "init_database_sec_diff"
                            }))
    except Exception as err:
        list_tmp = exceptionHandler(err)
        return JSONResponse(status_code=list_tmp[1], content=(list_tmp[0]))