# Get Data Securely(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 the Database table specified in the input. The result is stored in the given dynamic variable for further use during test execution.

{% hint style="info" %}
**Note**: The DB password must be encrypted using the AES encryption method. For more information, [**click here**](/avo-assure/utilities/encryption.md).
{% endhint %}

## Syntax&#x20;

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

| 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>\<encrypted DB password><br>(Required)</p>            | Provide the encrypted 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)`

| 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 Securely Action

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

* **Action**: Get Data Securely(DB)
* **Input Value**: sp-lively-glitter-a00wuaj6 pooler.eastus.azure.neon.tech;5432;John;FbSveCI31T0LIRLTdqsw==;Student;SELECT \* FROM district WHERE district ILIKE 'Rajbari';14
  * The first argument (**sp-lively-glitter-a00wuaj6-pooler.eastus.azure.neon.tech**) specifies the Database server hostname.
  * The second argument (**5432**) specifies the port number used to establish the Database connection.
  * The third argument (**John**) specifies the Database username.
  * The fourth argument (**FbSveCI31T0LIRLTdqsw==**) specifies the encrypted password of the  Database.
  * The fifth argument (**Student**) 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 Securely(DB)** action reads the value from the **Input Value** column (**sp-lively-glitter-a00wuaj6 pooler.eastus.azure.neon.tech;5432;John;FbSveCI31T0LIRLTdqsw==;Student;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="/files/T1uQXh9kqLruIBs01JKt" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.avoautomation.com/avo-assure/actions/generic/database-operations/get-data-securely-db.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
