# MySQL

MySQL component helps connect MySQL database and perform database-oriented actions such as executing queries, updating details and reading table information.

MySQL component in ZBrain flow allows performing these actions:

1. **Delete Row**: Deletes one or more rows from a table.
2. **Execute Query**: Executes a query on the MySQL database and returns the results.
3. **Find Rows**: Reads rows from a table in the database.
4. **Get Tables**: Returns a list of tables in the database.
5. **Insert Row**: Inserts a new row into a table.
6. **Update Row**: Updates one or more rows in a table.

### **How to Connect MySQL Component to ZBrain Flow?** <a href="#how-to-connect-mysql-component-to-zbrain-flow" id="how-to-connect-mysql-component-to-zbrain-flow"></a>

To integrate MySQL with ZBrain Flow, follow these steps to select and utilize the desired capabilities:

1. **Search for the MySQL Component**: Begin by locating the MySQL component within the ZBrain interface.
2. **Select the Required Capability**: Select the required capability to perform the desired action:
   1. **Delete Row**: Deletes one or more rows from a table.
   2. **Execute Query**: Executes a query on the MySQL database and returns the results.
   3. **Find Rows**: Reads rows from a table in the database.
   4. **Get Tables**: Returns a list of tables in the database.
   5. **Insert Row**: Inserts a new row into a table.
   6. **Update Row**: Updates one or more rows in a table.

#### **Additional Settings for MySQL Find Row** <a href="#additional-settings-for-mysql-find-row" id="additional-settings-for-mysql-find-row"></a>

Select the database connection to use for executing queries within MySQL.

For connection establishment, the following fields are needed:

* **Connection Name**: Assign a unique name to this database connection for easy identification within your system.
* **Host**: Enter the hostname or IP address of the MySQL server to establish a connection.
* **Port**: Specify the port number used to connect to the MySQL server, typically 3306 for MySQL databases.
* **Username**: Provide the username authorized to access the MySQL server.
* **Password**: Input the password associated with the username for authentication on the MySQL server.
* **Database**: Name the specific database on the MySQL server you wish to connect to for executing queries.
* **Save Connection:** Save the connection by pressing the save button.

After connecting the MYSQL database, these settings need to be configured:

* **Timezone**: Specify the timezone setting for the MySQL server to ensure time-sensitive queries are accurate.
* **Table**: Choose the table from your database where the search will be executed.
* **Condition**: Define SQL conditions, including logic operators, to specify which rows should be retrieved.
* **Arguments**: List the arguments that correspond to placeholders in the condition to safely pass dynamic values.
* **Columns**: Select specific columns to include in the output, tailoring the data retrieval to your needs.

#### **Additional Settings for MySQL Insert Row** <a href="#additional-settings-for-mysql-insert-row" id="additional-settings-for-mysql-insert-row"></a>

* **Connection** Select the pre-configured database connection to use for inserting data into a MySQL table.
* **Timezone**: Set the timezone that should be used by the MySQL server, ensuring that time-based operations are accurately timed.
* **Table**: Choose the table within the selected database where the new row will be inserted.
* **Values**: Provide the data for each column in the table where the row is to be inserted, formatted as key-value pairs.

#### **Additional Settings for MySQL Update Row** <a href="#additional-settings-for-mysql-update-row" id="additional-settings-for-mysql-update-row"></a>

* **Connection**: Choose a database connection to perform the update operation within a MySQL database.
* **Timezone**: Specify the timezone for the MySQL server, which can affect timestamp data and query scheduling.
* **Table**: Select the table where the update operation will be executed.
* **Values**: Input the new data for the update, formatted as key-value pairs where keys are column names and values are the new data for those columns.
* **Search Column**: Specify the column used to identify the row(s) that need updating.
* **Search Value**: Define the value in the search column that will pinpoint the row(s) to be updated.

#### **Additional Settings for MySQL Delete Row** <a href="#additional-settings-for-mysql-delete-row" id="additional-settings-for-mysql-delete-row"></a>

* **Connection**: Select the database connection that will be used to access the MySQL server for the delete operation.
* **Timezone**: Choose the timezone setting for the MySQL server to ensure accurate timing for operations that are time-sensitive.
* **Table**: Identify the table from which rows will be deleted.
* **Search Column**: Specify the column to be searched to locate the row(s) for deletion.
* **Search Value**: Enter the value in the search column that identifies the row(s) to be deleted.

#### **Additional Settings for MySQL Get Tables** <a href="#additional-settings-for-mysql-get-tables" id="additional-settings-for-mysql-get-tables"></a>

* **Connection**: Choose a database connection to query the MySQL server and retrieve a list of tables.

#### **Additional Settings for MySQL Executive Query** <a href="#additional-settings-for-mysql-executive-query" id="additional-settings-for-mysql-executive-query"></a>

* **Connection**: Select the database connection that will be used for executing SQL queries on a MySQL server.
* **DO NOT use dynamic input directly**: Emphasizes the importance of avoiding direct dynamic inputs in the query string to prevent SQL injection; use placeholders instead.
* **Timezone**: Specify the timezone for the MySQL server to ensure that operations involving time calculations are accurate.
* **Query**: Input the SQL query to be executed. Use placeholders (?) for any dynamic values to enhance security.
* **Arguments**: Provide the actual values for the placeholders used in the SQL query, ensuring the values are in the same order as the placeholders.


---

# 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.zbrain.ai/zbrain-documentation/zbrain-builder/zbrain-ai-agents/creating-custom-ai-agents/define-flow/mysql.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.
