Access denied while connecting MySql database in Robot framework

Viewed 51

Below is my code:

*** Settings ***
Documentation  Database Testing in Robot Framework
Library  DatabaseLibrary


*** Variables ***
${DBName}  custom_workflow
${username}  root@localhost
${password}  password
${DBHost}  localhost
${DBPort}  3306

*** Test Cases ***

Verify Successful creation of Table
    [documentation]  This test case verifies that user is able to create a table successfully
    Connect DB
    ${output}=  Execute SQL String  CREATE TABLE Persons (PersonID int, FirstName varchar(255), Address varchar(255), City varchar(255));

    Should Be Equal As Strings  ${output}  None

*** Keywords ***
Connect DB

    Connect To Database  pymysql   ${DBName}  ${username}  ${password}  ${DBHost} ${DBPort}

Disconnect DB
    Disconnect From Database


 

When i execute the above code it gets blocked with error:

OperationalError: (1045, "Access denied for user 'root@localhost'@'localhost' (using password: YES)")

I need help to understand this issue.

Robot Framework 5.0.1 (Python 3.10.4 on win32)

Can anyone here suggest me what is the issue?

I am getting below error:

PS C:\Users\ce\Downloads\Robot-Framework-master> robot Tests\DBConnection.robot
==============================================================================
DBConnection :: Database Testing in Robot Framework                           
==============================================================================
Verify Successful creation of Table :: This test case verifies tha... | FAIL |                       
OperationalError: (1045, "Access denied for user 'root@localhost'@'localhost' (using password: YES)")
------------------------------------------------------------------------------                       
DBConnection :: Database Testing in Robot Framework                   | FAIL |                       
1 test, 0 passed, 1 failed*                                                                           




              
1 Answers

Maybe the error message gives you an indication that the user name is wrong?

Remove the @localhost from the username:

${username}  root
Related