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
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
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
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
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
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
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