The port value did not pick correctly from variable from Robot framework while connecting the Microsoft SQL server management Studio

Hi,

I am tried to connect the Microsoft SQL server management Studio" database in Robot framework and port value is not picked correctly in variable in Robot Framework.
Note: with same value database connection is working correctly in .py file.
Please find attached screen shot for this.

here is the code:
*** Settings ***

Library DatabaseLibrary
Library OperatingSystem
Library SeleniumLibrary

*** Variables ***
${DbDriver} ODBC Driver 17 for SQL Server
${DbServer} server name

${dbName} dbname
${dbUsername} user name

${dbPassword} Testpassword
${dbPort} 1433
${DbAuthentication} ActiveDirectoryInteractive

*** Test Cases ***
Verify the sql Connection

set log level TRACE
When Verfy by the database connection

*** Keywords ***

Verfy by samta the database connection
Connect to Database pymysql ${DbDriver} ${DbServer} ${dbName} ${dbUsername} ${dbPassword} ${DbAuthentication} ${dbPort}

Here is the error:
(venv) PS C:\Users\Samta\PycharmProjects\SDHUI_RobotFramework_TestAutomation> Robot -d Results --variable var:chrome Testsuite\Samta_Execution\02_Request_Approval

02 Request Approval

02 Request Approval.DBTrail

Verify the sql Connection | FAIL |
ValueError: Argument ‘dbPort’ got value that cannot be converted to integer or None.

02 Request Approval.DBTrail | FAIL |
1 test, 0 passed, 1 failed

02 Request Approval | FAIL |
1 test, 0 passed, 1 failed

Log: C:\Users\Samta\PycharmProjects\SDHUI_RobotFramework_TestAutomation\Results\log.html
Report: C:\Users\Samta\PycharmProjects\SDHUI_RobotFramework_TestAutomation\Results\report.html
(venv) PS C:\Users\Samta\PycharmProjects\SDHUI_RobotFramework_TestAutomation>

Please advise me to fix this issue.

Hi Samta,

There seems to be more than 1 issue here:

  • Microsoft SQL server management Studio as far as I remember, this app can only connect to Microsoft SQL servers, not MySQL servers?, so the first argument after Connect to Database is probably wrong?, you probably also want to double check the value you gave for ${DbDriver}, It’s amazing how many people mix up mysql and mssql, I know there’s only one letter difference, but in your case i think what you want is pyodbc
  • The second issue is in the error message, the dbPort argument to Connect to Database got the value <password>, as this is clearly not the value you put in the variable ${dbPort} this means you need to fix the arguments to Connect to Database, they could be:
    • out of order?
    • you have too many
    • you are missing one (some?)
      what ever the cause, the variable that produced the value <password> is where ${dbPort} should be.

Hopefully that help you sort it out,

Dave.

Thanks, Dave for your support my issue got resolved.
Thanks for your call time to fix issue.

1 Like

This is below code I have used to fix this above issue, any option to connect to server u can use:
*** Settings ***

Library DatabaseLibrary
Library OperatingSystem
Library SeleniumLibrary
Library Telnet

*** Variables ***
${DbDriver} = ‘ODBC Driver 17 for SQL Server’
${DbServer} = ‘Server’
${dbName} = ‘Db namer’
${dbUsername}= ‘user name’
${dbPassword}= ‘password’
${DbAuthentication}= ‘ActiveDirectoryInteractive’
${dbPort}= ‘1433’

${DBHost_ConnectionString}= DRIVER=‘driver’,Server=‘server name’,PORT=1433,DATABASE=‘databaser’,UID=‘user name’,PWD=‘Password9’,Authentication=‘ActiveDirectoryInteractive’

*** Test Cases ***
Verify the sql Connection

set log level TRACE
When Verify by samta the database connection

*** Keywords ***

Verify by samta the database connection

Connect To Database Using Custom Params      pyodbc      DRIVER=${DbDriver},Server=${DbServer},PORT=${dbPort},DATABASE=${dbName},UID=${dbUsername},PWD=${dbPassword},Authentication=${DbAuthentication}
#Connect To Database Using Custom Params       pyodbc      ${DBHost_ConnectionString}
2 Likes