문제

If anyone knows, how to connect to the Database(db2) using using RobotFrame work. I want to query database to verify the results.

any Idea would be appreciated !

Br

도움이 되었습니까?

해결책

  1. If you have working python code to connect to the database, just write a library for robot framework on top of it.
  2. Of course, there is A Database Library Already, maybe it can meet your requirements, or you'd have to go back to plan 1.

Good luck.

다른 팁

Please install DatabaseLibrary into you machine and install it. Make sure that pymysql is already available into your system, if not then please install it also.

Please follow the keywords given here.

Here I have written one successful rf script through which you can connect to your database:

***Settings*** 
Library  DatabaseLibrary
***Testcases***
TestCase

   Connect To Database Using Custom Params  pymssql  'DatabaseName', 'UserName', 'Password', 'ip address of the machine where this database is installed'
   @{S}  Execute Sql String  select * from TableName;
import pymysql.cursors

def Delete_Fund(Name):
connection = pymysql.connect(host='ip',
                         user='root',
                         password='mysql',
                         port=3306,
                         database='novobank_auto',
                         cursorclass=pymysql.cursors.DictCursor)
try:
    with connection.cursor() as cursor:
        sql1 = "SET @fundName = '" + fundName + "';"
        cursor.execute(sql1)
        sql2 = "DELETE FROM `m_fund` WHERE `name` = @fundName;"
        cursor.execute(sql2)
        connection.commit()
        print("Fund : "+fundName+" has been Deleted")
finally:
    connection.close()

Delete_Fund("Name")

For any database we need to establish the connection first and than execute the queries.

We have to follow 2 steps as below:-

  1. Connecting to database need to install the database library (which contain the default keywords.
  2. Install drivers lets say SQL drivers or Mysql drivers.

After the installation include the databaselibrary in robot framework and use the keywords provided by this library example like

Connect To Database pymssql ${dbName} ${dbUsername} ${dbPassword} ${dbHost}

Complete step by step instructions to connect database with robot framework

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top