Overview
This node allows users to perform SQL operations on a Turso database, specifically focusing here on the Select Rows operation. It enables selecting rows from a specified table with flexible options such as choosing specific columns or all columns, filtering results using a WHERE clause, ordering results by a column, and limiting the number of returned rows with an offset.
Common scenarios where this node is beneficial include:
- Retrieving filtered data subsets from a database for further processing.
- Extracting sorted lists of records based on user-defined criteria.
- Paginating query results by applying limits and offsets.
- Selecting either specific columns or all columns depending on the use case.
Practical example:
- Select all users from a "users" table who have a status of "active", order them by their creation date descending, and limit the output to 50 records starting from the 10th record.
Properties
| Name | Meaning |
|---|---|
| Table Name | The name of the database table to select rows from. |
| Columns | Specific columns to include in the result set. Must select at least one if not selecting all columns. |
| Select All Columns | Boolean flag to select all columns (*) instead of specifying individual columns. |
| Use Where Clause | Boolean flag indicating whether to apply a WHERE clause to filter the results. |
| Where Clause | The condition expression for filtering rows (without the WHERE keyword). Required if "Use Where Clause" is enabled. |
| Where Parameters | List of parameter values corresponding to placeholders (?) in the WHERE clause, applied in order. |
| Use Order By | Boolean flag indicating whether to sort the results by a specific column. |
| Order By | The column name to order the results by. Required if "Use Order By" is enabled. |
| Order Direction | Direction of sorting: Ascending (ASC) or Descending (DESC). |
| Use Limit | Boolean flag indicating whether to limit the number of results returned. |
| Limit | Maximum number of rows to return. Must be greater than 0. Required if "Use Limit" is enabled. |
| Offset | Number of rows to skip before starting to return rows. Used for pagination. Defaults to 0. |
Output
The output JSON contains the following structure:
columns: An array of column names included in the result set.rows: An array of row objects, each representing a record fetched from the database. Each object maps column names to their respective values.
Example output JSON snippet:
{
"columns": ["id", "name", "email"],
"rows": [
{ "id": 1, "name": "Alice", "email": "alice@example.com" },
{ "id": 2, "name": "Bob", "email": "bob@example.com" }
]
}
The node does not output binary data for this operation.
Dependencies
- Requires connection credentials to a Turso database, including:
- A valid database URL.
- An authentication token.
- Uses the Turso client library to execute SQL queries.
- The node expects these credentials to be configured properly in n8n before execution.
Troubleshooting
- Empty or missing table name: The node requires a valid table name; ensure it is provided.
- No columns selected when not selecting all: At least one column must be selected unless "Select All Columns" is enabled.
- Invalid or empty WHERE clause when enabled: If "Use Where Clause" is true, the WHERE clause cannot be empty.
- Mismatch between WHERE clause placeholders and parameters: Ensure the number of parameters matches the number of
?placeholders in the WHERE clause. - Order By column missing when enabled: When "Use Order By" is true, a valid column must be selected.
- Limit must be positive: If "Use Limit" is enabled, the limit value must be greater than zero.
- Connection errors: Verify that the database URL and authentication token are correct and that the Turso database is accessible.
- SQL errors: Errors in SQL syntax or invalid column/table names will throw descriptive errors referencing the operation and item index.