Database Connector

Certain test scenarios may require you to pull information directly from your database into RapidAPI Testing. For example, you may want to validate that a GET request returns information that is consistent with what is in the database. Another example might be that as test data, you want to use data that closely matches your real-world records.

RapidAPI Testing supports these scenarios through a test step called “Database Connector”. As a summary, this step allows you to do the following.

  • Run a query against your database (you will supply the database information, credentials, as well as the query).
  • Use the query results as data for your subsequent test steps.

We currently support the following database types. Please let us know if you would like to see more.

  1. MySQL
  2. PostgreSQL
  3. Microsoft SQL Server

Now, we are going to go over how this works! First, let’s add a step called “Database Connector” to your test.

In the new test block that appears, we will do a few things.

  • First, select the database type that you are connecting to.
  • You will also want to define the variable where the query result will be stored. This is the test variable that you will use in the subsequent steps to access the query result. Keep in mind that the test results will be stored in the variable as an array of objects.
  • Lastly, you can enter the database information under “Connection settings”, such as the credentials, host, etc. You can hit “Test Connection” to see whether we are able to connect to your database directly. If successful, you will see a success mark next to it. Otherwise, you will see an error message.

Then, shift over to the “Query” tab, where you will enter your query. Once you have entered the query, you can hit “Test Query” to verify that the query is doing what you want it to do. You will see the results as it is stored in the test variable you defined earlier.

That is it! Now you are ready to use the query results through your defined variable in your subsequent steps.