Overview
The TiDB Cloud node for n8n allows you to execute SQL queries directly against a TiDB Cloud database.
With the Default resource and the Execute SQL operation, this node is designed to run arbitrary SQL statements (such as SELECT, INSERT, UPDATE, or any valid SQL) on your specified TiDB Cloud cluster and return the results.
Common scenarios:
- Querying data from TiDB Cloud for use in subsequent workflow steps.
- Automating reporting by running complex SQL queries.
- Integrating TiDB Cloud with other systems via n8n workflows.
Practical example:
You could use this node to fetch all products with an ID less than 40:
SELECT id, name FROM product WHERE id < 40
and then process or send that data elsewhere in your automation.
Properties
| Name | Type | Meaning |
|---|---|---|
| Project | Resource Locator | The TiDB Cloud project to operate within. Required to identify the correct environment. |
| Cluster | Resource Locator | The specific TiDB Cloud cluster where the query will be executed. |
| User | Resource Locator | The database user account used for authentication. |
| Database | String | The name of the database within the cluster to run the query against. |
| Password | String (Password) | The password for the specified database user. |
| SQL | String | The SQL query to execute. This must be a valid SQL statement. |
Output
- The output is a JSON array containing the result rows of the executed SQL query.
- Each item in the array represents a row returned by the query, with properties corresponding to the selected columns.
- If an error occurs and "Continue On Fail" is enabled, the output will contain an object with an
errorproperty describing the issue.
Example output:
[
{ "id": 1, "name": "Product A" },
{ "id": 2, "name": "Product B" }
]
If there is an error and "Continue On Fail" is enabled:
[
{ "error": "Syntax error in SQL statement" }
]
Dependencies
- External Service: Requires access to a TiDB Cloud instance.
- Credentials: You must configure the
tiDBCloudApicredential in n8n with appropriate API keys or connection details. - n8n Configuration: No special environment variables are required beyond standard credential setup.
Troubleshooting
Common issues:
- Authentication errors: Ensure the Project, Cluster, User, and Password are correct and have sufficient permissions.
- SQL syntax errors: Double-check your SQL statement for typos or invalid syntax.
- Connection failures: Make sure your n8n instance can reach the TiDB Cloud endpoint (network/firewall issues).
- Missing parameters: All required fields (Project, Cluster, User, Database, Password, SQL) must be filled.
Error messages:
"ER_ACCESS_DENIED_ERROR": Invalid credentials; verify User and Password."Unknown database": The specified Database does not exist in the Cluster."Syntax error in SQL statement": There is a problem with your SQL; review and correct it."The operation \"...\" is not supported!": You selected an unsupported operation; ensure "Execute SQL" is chosen.
How to resolve:
- Check all input fields for correctness.
- Test the connection using the credential test feature in n8n.
- Review the SQL statement for errors.
- Consult TiDB Cloud documentation for permission and connectivity requirements.
Links and References
- TiDB Cloud Documentation
- n8n Documentation: Custom Nodes
- SQL Syntax Reference (TiDB is MySQL compatible)