示例#1
0
def db_connection(config):
    try:
        db = utils.Database(d_config.get(config))  # Initiate DB connection with MYSQL config
    except Exception as e:
        print("[ERROR] Database Connection Fail: {}".format(e))
        raise utils.DatabaseError(e)
    return db
示例#2
0
def get_cursor_query(sqlQuery):
    dbConn = db_connection('METASTORE')
    try:
        result, header = dbConn.sql(sqlQuery)
    except Exception as e:
        print("[ERROR] Error while generating the subset of data during the query execution: {}".format(e))
        raise utils.DatabaseError(e)

    return result, header
        utils.write_log(log, "[INFO] Batch Key: {}".format(BATCH_KEY))
        if args.singlefile:
            utils.write_log(log, "[OPTION] Single file mode: ON")
        if args.profiling:
            utils.write_log(log, "[OPTION] Profliling: ON")
        if args.automode:
            utils.write_log(log, "[OPTION] Auto Mode: ON")
        utils.write_log(log, "")
        utils.write_log(log, "[ACTION] Connecting to the database...")
        try:
            db = utils.Database(d_config.get(
                'MYSQL'))  # Initiate DB connection with MYSQL config
        except Exception as e:
            utils.write_log(
                log, "[ERROR] Database Connection Fail: {}".format(str(e)))
            raise utils.DatabaseError(e)
        else:
            utils.write_log(log, "")
            utils.write_log(log, "---------- -------------------- ----------")
            utils.write_log(log, "---------- CREATE LOCAL FOLDERS ----------")
            utils.write_log(log, "---------- -------------------- ----------")
            argList = [SOURCE_MASK, SOURCE_PATH]
            returncode, err = run_script(PYTHON_EXE,
                                         "P02_CreateLocalFolders.py", argList)
            if returncode != 0:
                error_display(err)
                raise utils.ScriptError(err)

            if args.automode:
                utils.write_log(log, "")
                utils.write_log(log, "---------- --------- ----------")