docs/guides/agent/agent_component_reference/execute_sql.md
A tool that execute SQL queries on a specified relational database.
The Execute SQL tool enables you to connect to a relational database and run SQL queries, whether entered directly or generated by the system’s Text2SQL capability via an Agent component.
You can pair an Agent component with the Execute SQL tool, with the Agent generating SQL statements and the Execute SQL tool handling database connection and query execution. An example of this setup can be found in the Text-to-SQL data expert Agent template shown below:
This text input field allows you to write static SQL queries, such as SELECT * FROM my_table, and dynamic SQL queries using variables.
:::tip NOTE
Click (x) or type / to insert variables.
:::
For dynamic SQL queries, you can include variables in your SQL queries, such as SELECT * FROM /sys.query; if an Agent component is paired with the Execute SQL tool to generate SQL tasks (see the Examples section), you can directly insert that Agent's output, content, into this field.
The supported database type. Currently, the following database types are available:
Appears only when you select Split as method.
The username with access privileges to the database.
The IP address of the database server.
The port number on which the database server is listening.
The password for the database user.
The maximum number of records returned by the SQL query to control response size and improve efficiency. Defaults to 1024.
The Execute SQL tool provides two output variables:
formalized_content: A string. If you reference this variable in a Message component, the returned records are displayed as a table.json: An object array. If you reference this variable in a Message component, the returned records will be presented as key-value pairs.