Overview
This node allows executing multiple SQL queries as a batch on a Turso database. It is useful when you need to run several related SQL commands in one go, such as inserting multiple records, updating various rows, or running a series of select statements. This batch execution can improve efficiency by reducing the number of separate database calls.
Practical examples include:
- Running multiple insert or update queries to modify different tables or rows.
- Executing a set of select queries to retrieve diverse data sets simultaneously.
- Performing complex transactional operations that require multiple SQL statements executed sequentially.
Properties
| Name | Meaning |
|---|---|
| Queries | A collection of SQL queries to execute as a batch. Each query includes: |
| - Query: The SQL statement to execute (required). | |
| - Parameters: Optional comma-separated list of parameters for the SQL query. |
Output
The output is an array where each element corresponds to the result of one query in the batch. Each element contains:
columns: An array of column names returned by the query (if applicable).rows: An array of row objects resulting from the query.rowsAffected: Number of rows affected by the query (for insert/update/delete).lastInsertRowid: The ID of the last inserted row (if applicable).
This structured output allows you to handle results from multiple queries distinctly.
Dependencies
- Requires a Turso database connection with a valid database URL and authentication token.
- Needs proper credentials configured in n8n to connect securely to the Turso database.
- Uses the
@libsql/clientlibrary internally to communicate with the Turso database.
Troubleshooting
- Empty Query Error: If any query string is empty or only whitespace, the node throws an error indicating the SQL query cannot be empty. Ensure all queries are properly defined.
- Connection Errors: Errors related to connection issues suggest checking the database URL and authentication token credentials.
- Parameter Mismatch: Parameters must be provided as a comma-separated list matching the placeholders in the SQL query; otherwise, errors may occur.
- Batch Size: At least one query must be provided in the batch; an empty batch will cause an error.
- Error Messages: Database-specific errors are wrapped with context about which query caused the failure, aiding debugging.