示例#1
0
def change_userPass(userName, userPass, postgre_path_to_bin=''):
    postgreLoginRoot = get_postgreLoginSrting(
        install_params['PostgreSQL']['root'])
    if (base.exec_command_in_dir(
            postgre_path_to_bin, postgreLoginRoot + '-c "ALTER USER ' +
            userName + " WITH PASSWORD '" + userPass + "';" + '"') != 0):
        return False
    return True
示例#2
0
def create_postgreUser(userName, userPass, postgre_path_to_bin=''):
    postgreLoginRoot = get_postgreLoginSrting(
        install_params['PostgreSQL']['root'])
    if (base.exec_command_in_dir(
            postgre_path_to_bin, postgreLoginRoot + '-c "CREATE USER ' +
            userName + ' WITH password ' + "'" + userPass + "'" + ';"') != 0):
        return False
    return True
示例#3
0
def create_postgreDb(dbName, postgre_path_to_bin=''):
    postgreLoginUser = get_postgreLoginSrting(
        install_params['PostgreSQL']['root'])
    if (base.exec_command_in_dir(
            postgre_path_to_bin,
            postgreLoginUser + '-c "CREATE DATABASE ' + dbName + ';"') != 0):
        return False
    return True
示例#4
0
def set_dbPrivilegesForUser(userName, dbName, postgre_path_to_bin=''):
    postgreLoginUser = get_postgreLoginSrting(
        install_params['PostgreSQL']['root'])
    if (base.exec_command_in_dir(
            postgre_path_to_bin,
            postgreLoginUser + '-c "GRANT ALL privileges ON DATABASE ' +
            dbName + ' TO ' + userName + ';"') != 0):
        return False
    return True
示例#5
0
def configureDb(userName, dbName, scriptPath, postgre_path_to_bin=''):
    print('Execution ' + scriptPath)
    postgreLoginSrt = get_postgreLoginSrting(userName)

    code = base.exec_command_in_dir(
        postgre_path_to_bin,
        postgreLoginSrt + ' -d ' + dbName + ' -f "' + scriptPath + '"')
    if (code != 0):
        print('Execution failed!')
        return False
    print('Execution completed')
    return True
示例#6
0
def execMySQLScript(mysql_path_to_bin, scriptPath):
    print('Execution ' + scriptPath)
    mysqlLoginSrt = get_mysqlLoginSrting()

    code = base.exec_command_in_dir(
        mysql_path_to_bin,
        get_mysqlLoginSrting() + ' < "' + scriptPath + '"')
    if (code != 0):
        print('Execution failed!')
        return False
    print('Execution completed')
    return True
示例#7
0
def set_MySQLEncrypt(mysql_path_to_bin, sEncrypt):
    print('Setting MySQL password encrypting...')

    code = base.exec_command_in_dir(
        mysql_path_to_bin,
        get_mysqlLoginSrting() + ' -e "' + "ALTER USER '" +
        install_params['MySQLServer']['user'] +
        "'@'localhost' IDENTIFIED WITH " + sEncrypt + " BY '" +
        install_params['MySQLServer']['pass'] + "';" + '"')
    if (code != 0):
        print('Setting password encryption failed!')
        return False

    print('Setting password encryption completed')
    return True