Database Insertion

This lesson will show how to insert data generated by a single Domain into a Database Table within a Database. For this example, we will be showing how to do this with a MySQL database. However, the same steps can be used to insert data into other databases as well.


Steps in Lesson 1 of this Training Module must be completed before completing the steps outlined in this lesson:

  1. Download the appropriate JDBC driver for the database.
  2. Create a database connection properties file.
  3. Add or update the Organization Resource.

Insert Receivers

GenRocket provides specific Receivers for inserting data into a database. For this example, the MySQLInsertReceiver will be used.

Empty Database Table

For this example, we will be inserting twenty-five user records into a User Table within a MySQL database named user_db. We will be emptying the database table before getting started.

Initial Setup

For this example, a User Domain has been added with four Attributes. The loopCount has been set to 25, and a Scenario has been added to the Domain.

Step 1: Add the Insert Receiver

An Insert Receiver will need to be added to the Domain before data can be inserted into a database. For this example, the MySQLInsertReceiver will be added to the Domain.

Note: For more information on how to add a Receiver to a Domain, click here.

Step 2: Configure the Receiver Parameters

Receiver Parameter changes will need to be made before inserting data into a database. The following Parameters will need to be configured for this example:

  • resourceName – Name of the file.
  • databaseName – Name of the database.
  • tableName – Name of the database table.

The default values will be used for all other Receiver Parameters in this example. Remember to click the Save button after making any Receiver Parameter changes.

Step 3: Receiver Attributes Property Keys Column Name

The columnName Receiver Attribute Property Key for each Attribute will need to match the actual column name within the database table.

Select the Attributes Property Keys Tab within the Receiver Dashboard to view this information.

The database table column name for the Receiver will default to the same name as the Attribute. This will need to be changed for each Attribute to ensure it matches the actual table column name within the database table.

To do so, complete the following steps for each Receiver Attribute:

  • Click on the first Attribute Name. For this example, the id Attribute is chosen.

  • Then enter a different columnName for the Attribute and click the Save & Next button to move to the next Attribute.

Once finished, the Attributes Property Keys Tab will appear as shown below:

Step 4: Download the Scenario

Next, the user will need to download the Scenario to their local machine. This can be done by clicking on the Download (Cloud) icon within the Project Dashboard or Domain Dashboard.

Step 5: Run the Scenario

On the user’s local machine, open a Command Prompt or Terminal window.

Then make sure the directory matches the path entered for the within the GenRocket web platform.

Next, enter genrocket -r <ScenarioName.grs>. Replace <ScenarioName.grs> with the actual Scenario File Name. Then press the Enter key.

Database Table Data

As shown below, twenty-five records have been inserted into the User Table within the user_db Database.

Related Assets

GenRocket - Test Data Management

Download Literature

View Literature
GenRocket - Test Data Management

View Blog

Read More
GenRocket - Test Data Management

How can we help
you today?

Request a Demo

See how GenRocket can solve your toughest test data challenge with quality synthetic data by-design and on-demand