Importing Data from a Database - WinRunner

In order to import data from an existing database into a data table, you must specify the data to import using the DataDriver wizard. If you selected the Import data from a database check box, the DataDriver wizard prompts you to specify the program you will use to connect to the database. You can select either ODBC/Microsoft Query or Data Junction.

Note that in order to import data from a database, Microsoft Query or Data Junction must be installed on your machine. You can install Microsoft Query from the custom installation of Microsoft Office. Note that Data Junction is not automatically included in your WinRunner package. To purchase Data Junction, contact your Mercury Interactive representative.

Importing Data from a Database Using Microsoft Query

You can use Microsoft Query to choose a data source and define a query within the data source.

Note that WinRunner supports the following versions of Microsoft Query:

  • version 2.00 (part of Microsoft Office 95)
  • version 8.00 (part of Microsoft Office 97)
  • version 2000 (part of Microsoft Office 2000)
  • version 2002 (part of Microsoft Office XP)

Setting the Microsoft Query Options

After you select Microsoft Query in the Connect to database using option, the following wizard screen opens:

Setting the Microsoft Query Options
You can choose from the following options:

  • Create new query: Opens Microsoft Query, enabling you to create a new ODBC *.sql query file with the name specified below. For additional information, see “Creating a New Source Query File”
  • Copy existing query: Opens the Select source query file screen in the wizard, which enables you to copy an existing ODBC query from another query file. For additional information, see “Selecting a Source Query File”
  • Specify SQL statement: Opens the Specify SQL statement screen in the wizard, which enables you to specify the connection string and an SQL statement. For additional information, see “Specifying an SQL Statement”
  • New query file: Displays the default name of the new *.sql query file for the data to import from the database. You can use the browse button to browse for a different *.sql query file.
  • Maximum number of rows: Select this check box and enter the maximum number of database rows to import. If this check box is cleared, there is no maximum. Note that this option adds an additional parameter to your db_check statement.
  • Show me how to use Microsoft Query: Displays an instruction screen.

Creating a New Source Query File

Microsoft Query opens if you chose Create new query in the last step. Choose a new or existing data source, define a query, and when you are done:

  • In version 2.00, choose File > Exit and return to WinRunner to close Microsoft Query and return to WinRunner.
  • In version 8.00, in the Finish screen of the Query Wizard, click Exit and return to WinRunner and click Finish to exit Microsoft Query.

Alternatively, click View data or edit query in Microsoft Query and click Finish. After viewing or editing the data, choose File > Exit and return to WinRunner to close Microsoft Query and return to WinRunner.

Once you finish defining your query, you return to the DataDriver wizard to finish converting your test to a data-driven test.

Selecting a Source Query File

The following screen opens if you chose Copy existing query in the last step.
Selecting a Source Query File
Enter the pathname of the query file or use the Browse button to locate it. Once a query file is selected, you can use the View button to open the file for viewing.

Once you are done, you click Next to finish creating your data-driven test. For additional information, see step 4

Specifying an SQL Statement

The following screen opens if you chose Specify SQL statement in the last step.

Specifying an SQL Statement
In this screen you must specify the connection string and the SQL statement:

  • Connection String: Enter the connection string, or click Create to open the ODBC Select Data Source dialog box, in which you can select a *.dsn file, which inserts the connection string in the box.
  • SQL: Enter the SQL statement.

Once you are done, you click Next to finish creating your data-driven test.

Once you import data from a database using Microsoft Query, the query information is saved in a query file called msqrN.sql (where N is a unique number). By default, this file is stored in the test folder (where the default data table is stored). The DataDriver wizard inserts a ddt_update_from_db statement using a relative path and not a full path. During the test run, when a relative path is specified, WinRunner looks for the query file in the test folder.

If the full path is specified for a query file in the ddt_update_from_db statement, then WinRunner uses the full path to find the location of the query file.

Importing Data from a Database Using Data Junction

You can use Data Junction to create a conversion file that converts a database to a target text file.

Note that WinRunner supports versions 6.5 and 7 of Data Junction.

Setting the Data Junction Options

If Data Junction is installed on your machine, the following wizard screen opens once you choose to import data from a Data Junction database:

Setting the Data Junction Options
You can choose from the following options:

  • Create new conversion: Opens Data Junction and enables you to create a new conversion file. For additional information, see “Creating a Conversion File in Data Junction”
  • Use existing conversion: Opens the Select conversion file screen in thewizard, which enables you to specify an existing conversion file.
  • Show me how to use Data Junction (available only when Create new conversion is selected): Displays instructions for working with Data Junction.

Creating a Conversion File in Data Junction

  1. Specify and connect to the source database.
  2. Select an ASCII (delimited) target spoke type and specify and connect to the target file. Choose the “Replace File/Table” output mode.
  3. Map the source file to the target file.
  4. When you are done, click File > Export Conversion to export the conversion to a *.djs conversion file.
  5. The DataDriver wizard opens to the Select conversion file screen. Follow the instructions in “Selecting a Data Junction Conversion File”

Selecting a Data Junction Conversion File

The following wizard screen opens when you are working with Data Junction.

Selecting a Data Junction Conversion File
Enter the pathname of the conversion file or use the Browse button to locate it. Once a conversion file is selected, you can use the View button to open the Data Junction Conversion Manager if you want to view the file.

You can also choose from the following options:

Copy conversion to test directory: Copies the specified conversion file to the test folder.

Maximum number of rows: Select this check box and enter the maximum number of database rows to import. If this check box is cleared, there is no maximum.

Once you are done, you click Next to finish creating your data-driven test.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

WinRunner Topics