Knowledge Base | Base de connaissances

Page tree
Skip to end of metadata
Go to start of metadata

The database library is already included and available to be used in Askida CT. 

You can access this library directly in the scripting section of Askida CT in the same way you access any other library, simply add a new line of script, and then type the word Database for Askida CT to automatically show you the available options for this library.

Here are a couple of simple examples of how to use this library to connect to SQL, Oracle, DB2, SQL Server and My SQL, 

PostgreSQL

  • Library.Keyword: DatabaseLibrary.Connect To Database
    • dbApiModuleName: psycopg2
    • dbName: database name
    • dbUsername: username used to connect to database
    • dbPassword: password related to the username
    • dbHost: host where the database is located
    • dbPort: database port
  • Example:


PostgreSQL Database Connection Example
DatabaseLibrary.Connect To Database    dbapiModuleName=psycopg2    dbName=petclinic    dbUsername=petclinic    dbPassword=root    dbHost=ct-demo.askida.lan    dbPort=9091
DatabaseLibrary.Table Must Exist    vets    
DatabaseLibrary.Row Count Is Equal To X    select * from vets    6    
DatabaseLibrary.Check If Exists In Database    select * from vets where first_name = 'James'    
DatabaseLibrary.Disconnect From Database



Oracle

  • Library.Keyword: DatabaseLibrary.Connect To Database Using Custom Params
    • dbApiModuleName: jaydebeapi
    • dbConnectString: 'oracle.jdbc.driver.OracleDriver', 'jdbc:oracle:thin:@HOST:PORT/DB_NAME', ['USERNAME', 'PASSWORD']
  • Driver required on server: ojdbc8.jar (Oracle JDBC Driver 18.3)
  • Compatible with the following versions:
    • Oracle 18.3
    • Oracle 12.2
    • Oracle 12.1
    • Oracle 11.2.0.x
  • Example:

Oracle Database Connection Example
DatabaseLibrary.Connect To Database Using Custom Params    dbapiModuleName=jaydebeapi    db_connect_string='oracle.jdbc.driver.OracleDriver', 'jdbc:oracle:thin:@${DATABASE_SERVER_NAME}:49161/xe', ['system', 'oracle']
${first_name_male}    FakerLibrary.First Name Male
DatabaseLibrary.Execute Sql String    insert into employee (name) values ('${first_name_male}')    sansTran=true
${first_name_female}    FakerLibrary.First Name Female
DatabaseLibrary.Execute Sql String    insert into employee (name) values ('${first_name_female}')    sansTran=true
@{query_result}    DatabaseLibrary.Query    select * from employee    sansTran=true
BuiltIn.Log    ${query_result}                
DatabaseLibrary.Disconnect From Database


DB2

  • Library.Keyword: DatabaseLibrary.Connect To Database Using Custom Params
    • dbApiModuleName: jaydebeapi
    • dbConnectString: 'com.ibm.db2.jcc.DB2Driver', 'jdbc:db2://HOST:PORT/DB_NAME', ['USERNAME', 'PASSWORD']
  • Driver required on server: db2jcc-db2jcc4.jar
  • Compatible with the following versions:
    • DB2 11.1
    • DB2 10.5
    • DB2 10.1
    • DB2 9.7
    • DB2 9.5
  • Example:

DB2 Database Connection Example
DatabaseLibrary.Connect To Database Using Custom Params    dbapiModuleName=jaydebeapi    db_connect_string='com.ibm.db2.jcc.DB2Driver', 'jdbc:db2://${DATABASE_SERVER_NAME}:50000/SAMPLE', ['db2inst1', 'askidact']
@{query_result}    DatabaseLibrary.Query    select * from employee    
BuiltIn.Log    ${query_result}                
DatabaseLibrary.Disconnect From Database


SQL Server

  • Library.Keyword: DatabaseLibrary.Connect To Database Using Custom Params
    • dbApiModuleName: jaydebeapi
    • dbConnectString: 'com.microsoft.sqlserver.jdbc.SQLServerDriver', 'jdbc:sqlserver://HOST:PORT;database=DB_NAME', ['USERNAME', 'PASSWORD']
    • dbConnectString: 'com.microsoft.sqlserver.jdbc.SQLServerDriver', 'jdbc:sqlserver://HOST\\INSTANCE;database=DB_NAME', ['USERNAME', 'PASSWORD']
  • Driver required on server: mssql-jdbc-7.0.0.jre8.jar
  • Compatible with the following versions:
    • Azure SQL Managed Instance
    • SQL Server 2017
    • SQL Server 2016
    • SQL Server 2014
    • PDW 2008R2 AU34
    • Azure SQL Database 

    • SQL Server 2012  

    • SQL Server 2008R2

  • Example:

SQL Server Database Connection Example (using port)
DatabaseLibrary.Connect To Database Using Custom Params    dbapiModuleName=jaydebeapi    db_connect_string='com.microsoft.sqlserver.jdbc.SQLServerDriver', 'jdbc:sqlserver://sql-dev-mmq.askida.lan:1433;database=Claims_MMQ', ['sa', 'password_xxx']
@{query_result}    DatabaseLibrary.Query    select * from Accounts    sansTran=true
BuiltIn.Log    ${query_result}                
DatabaseLibrary.Disconnect From Database
SQL Server Database Connection Example (using instance)
DatabaseLibrary.Connect To Database Using Custom Params    dbapiModuleName=jaydebeapi    db_connect_string='com.microsoft.sqlserver.jdbc.SQLServerDriver', 'jdbc:sqlserver://sql-dev-mmq.askida.lan\\MMQSQLSERVER;database=Claims_MMQ', ['sa', 'password_xxx']
@{query_result}    DatabaseLibrary.Query    select * from Accounts    sansTran=true
BuiltIn.Log    ${query_result}                
DatabaseLibrary.Disconnect From Database


MySQL

  • Library.Keyword: DatabaseLibrary.Connect To Database Using Custom Params
    • dbApiModuleName: jaydebeapi
    • dbConnectString: 'com.mysql.jdbc.Driver', 'jdbc:mysql://HOST:PORT/DB_NAME', ['USERNAME', 'PASSWORD']
  • Driver required on server: mysql-connector-java-8.0.14.jar
  • Compatible with the following versions:
    • MySQL 8.0
    • MySQL 5.7
    • MySQL 5.6
    • MySQL 5.5
  • Example:

MySQL Databse Connection Example
DatabaseLibrary.Connect To Database Using Custom Params    dbapiModuleName=jaydebeapi    db_connect_string='com.mysql.jdbc.Driver', 'jdbc:mysql://ct-prod-test2.askida.lan:3306/askida', ['root', 'password']
@{query_result}     DatabaseLibrary.Query    select * from project    sansTran=true
BuiltIn.Log    ${query_result}    
DatabaseLibrary.Disconnect From Database
  • No labels