# Get Data(DB)

This is a pre-built Action located under the **@Generic Element**. The functionality of this Action in Avo Assure is to retrieve data from a Database table. The result is stored in the given dynamic variable for further use during test execution.

## Syntax&#x20;

**Input Value**: `<DB IP/instance name/DB file path>;<DB port>;<DB username>;<DB password>;<DB name>;<Query>;<DB Number/DB Tags>;<querytype/warehouse>(Optional);<schema>(Optional)`

| Argument                                                 | Description                                                                                               |
| -------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| <p>\<DB IP/instance name/DB file path><br>(Required)</p> | Provide the Database server location, instance name, or DB file path you want to use for retrieving data. |
| <p> \<DB port><br>(Required)</p>                         | Provide the port number you want to use for connecting with the Database.                                 |
| <p> \<DB username><br>(Required)</p>                     | Provide the username you want to use for Database access.                                                 |
| <p>\<DB Password><br>(Required)</p>                      | Provide the password associated with the username.                                                        |
| <p>\<DB name><br>(Required)</p>                          | Provide the name of the Database you want to connect with.                                                |
| <p>\<Query><br>(Required)</p>                            | Provide the SQL or Non-SQL query you want to execute.                                                     |
| <p>\<DB Number/DB Tags><br>(Required)</p>                | Provide the Database identifier you want to use for the connection.                                       |
| <p>\<querytype/warehouse><br>(Optional)</p>              | Provide the data container you want to target within the Database.                                        |
| <p>\<schema><br>(Optional)</p>                           | Provide the schema you want to use.                                                                       |

{% hint style="info" %}
**Note**:

* When providing the database connection details, you must provide the **Database IP address**, the **instance name**, or the **Database file path** in the input value.
* When you are providing the database identifier, you must provide the **Database Number** or the **Database Tags** in the input value, as required.
* When you are using a non-SQL query, you must provide the **querytype** or the **warehouse name** in the input value.&#x20;
  {% endhint %}

**Output Value**: `<Dynamic Variable>;<Dynamic Variable>(Optional)`&#x20;

| Argument                                  | Description                                                                                           |
| ----------------------------------------- | ----------------------------------------------------------------------------------------------------- |
| <p>\<Dynamic Variable><br>(Required)</p>  | This dynamic variable stores the data fetched from the Database.                                      |
| <p>\<Dynamic Variable><br>(Optional) </p> | <p>This dynamic variable stores the status as <strong>True</strong><br>or <strong>False</strong>.</p> |

### Example: Retrieving Data from a Database using the Get Data Action

In this example, we are explain how to retrieve data from a Database using the provided connection details and query.

* **Action**: Get Data(DB)
* **Input Value**: ep-lively-glitter-awuj6 pooler.eastus2.are.neon.tech;5472;neondb\_owner;npg\_6smlQSN2dBw;dvdrenl;SELECT \* FROM district WHERE district ILIKE 'Rajbari';14
  * The first argument (**ep-lively-glitter-awuj6 pooler.eastus2.are.neon.tech**) specifies the Database server hostname.
  * The second argument (**5472**) specifies the port number used to establish the Database connection.
  * The third argument (**neondb\_owner**) specifies the Database username.
  * The fourth argument (**npg\_6smlQSN2dBw**) specifies the Database password.
  * The fifth argument (**dvdrenl**) specifies the Database name.
  * The sixth argument **(SELECT \* FROM district WHERE district ILIKE 'Rajbari')** contains the SQL query to execute.
  * The seventh argument (**14**) specifies the Database number used for execution.
* **Output Value**: {DB\_Data}
  * The retrieved data from the Database is stored in the **{DB\_Data}** dynamic variable.&#x20;
  * If a second output variable is defined, it stores the action status with the following possible values:
    * **True**: If the data is retrieved successfully.
    * **False**: If the data is not retrieved successfully.
* **Logical Explanation**: The **Get Data (DB)** action reads the value from the **Input Value** column (**ep-lively-glitter-awuj6 pooler.eastus2.are.neon.tech;5472;neondb\_owner;npg\_6smlQSN2dBw;dvdrenl;SELECT \* FROM district WHERE district ILIKE 'Rajbari';14**). The action establishes a connection using the given Database credentials and executes the SQL query. The retrieved data is stored in the **{DB\_Data}** variable.

{% hint style="info" %}
**Note**: If you want to display the stored data, use the **Display Variable Value** action. In the **Input Value** column, provide the value in array format: **{VariableName\[row number]\[column number]}**.
{% endhint %}

<figure><img src="https://2174257472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fk8QZzXZMIJSStKAzDSTu%2Fuploads%2F9O64rrDniMloxYIkb3S3%2Fimage.png?alt=media&#x26;token=428a2d21-33ce-43d8-a994-612b8169d642" alt=""><figcaption></figcaption></figure>
