Steer databases

To steer databases, you have to create Database Engine 3.0 TestCases. The Standard subset contains all Modules that you need to create a database TestCase.

You can find these Modules under Standard modules->TBox XEngines->Database.

Structure of database TestCases

Database TestCases require the following base structure:

  1. Open a connection to a database.

  2. Run an operation on your database. You perform these operations through SQL statements.

  3. Close the connection.

The Database Engine 3.0 does not support mixed TestCases.

If you use the Database Engine 3.0 Module to open a connection, you must perform your database operations and then close the connection with Database Engine 3.0 Modules.

Use Modules to create your TestCase

You can perform the steps of your database TestCase in one of the following ways:

  • Use separate Modules: TBox DB Open Connection, TBox DB Run SQL Statement, and TBox DB Close Connection.

  • Use the TBox DB Expert module, which contains all steps in one Module.

For information on how to create TestSteps from Modules, see chapter "Creating TestSteps from Modules".

In this example, you use the TBox DB Expert module to perform the following actions:

  • Establish a connection to the database DB_Test with the user credentials of the user sa.

  • Save the connection under the name TestDatabase.

  • Check the database table Customers.

  • Save the street number in the first data row of the column Street Number to a Buffer named StreetNumberBuffer.

  • Close the connection.

Use the TBox DB Expert module in a TestCase

Export the result of an SQL Statement into a CSV file

You can export the result of your SQL Statement into a comma separated CSV file. You can do so for TestSteps created from the following Modules:

To export the result, follow the steps below:

  1. Enter the following command into the Value column of Result Table: {EXPORTTOCSV[<file path>]}

  2. Replace <file path> with the absolute path to the file.

    If the file doesn't exist, the Database Engine 3.0 creates it. If a file with the same name already exists, the Engine overwrites the existing file.

  3. Use the default ActionMode Select. The export also works with Input but none of the other ActionModes.

  4. To export the result table, run your TestCase.

In this example, Tosca exports the result table of your SQL Statement into the file Customers.csv located at C:\Temp.

Export to C:\Temp\Customers.csv