MySQL

Learn how to use the MySQL node in StackAI to run database queries, including required inputs, configurations, and output details with practical examples.

The MySQL Node in StackAI allows you to query a MySQL database directly from your workflow. It is designed to execute queries—either in plain English or SQL format—against your database and return structured results.

How to use it?

To use the MySQL node, you need to provide two required inputs:

  1. Schema (Required):

    • Description: The full database schema, including tables, columns, and data types.

    • Example:

      TABLE Customers (
        CustomerID INT,
        Name TEXT,
        Email TEXT,
        Country TEXT
      );
      TABLE Orders (
        OrderID INT,
        CustomerID INT,
        Amount DECIMAL,
        OrderDate DATE
      );
  2. Query (Required):

    • Description: The question or command you want to run. You can write this in plain English or as a SQL statement.

    • Example:

      • "Show me all customers from Canada."

      • "SELECT * FROM Orders WHERE Amount > 1000;"

Configurations There are no additional configuration parameters required for this node. All you need is the schema and the query.

Outputs The MySQL node provides two outputs:

  1. Query (Required):

    • Description: The actual SQL query that was executed, even if you provided a plain English question.

  2. Results (Required):

    • Description: The results of the query, returned as an array of objects (rows).

Example of Usage

Suppose you want to find all orders above $500:

  • Schema:

    TABLE Orders (
      OrderID INT,
      CustomerID INT,
      Amount DECIMAL,
      OrderDate DATE
    );
  • Query: "Show me all orders where the amount is greater than 500."

Expected Output:

  • Query: SELECT * FROM Orders WHERE Amount > 500;

  • Results:

    [
      { "OrderID": 101, "CustomerID": 1, "Amount": 750, "OrderDate": "2024-06-01" },
      { "OrderID": 102, "CustomerID": 3, "Amount": 1200, "OrderDate": "2024-06-02" }
    ]

Available Actions

  • database_query_mysql:

    • Description: Run a query (in plain English or SQL) against your MySQL database and get structured results.

Inputs for database_query_mysql:

  • sql_schema (Required): The database schema (tables, columns, types, etc.).

  • query (Required): The query in plain English or SQL.

Outputs for database_query_mysql:

  • query (Required): The SQL query that was executed.

  • results (Required): The results of the query as an array of objects.

Use the MySQL node in StackAI to seamlessly integrate database queries into your automated workflows, making data retrieval and analysis easy and efficient.

Last updated

Was this helpful?