libSQL
The libSQL component allows you to interact with libSQL or Turso databases in your Nappai workflows. It helps you read data, write new records, and update existing information securely. This node acts as the main connection point for database operations, enabling you to retrieve results and manage data within your automation processes.
How it Works
This component connects to your libSQL or Turso database using the credentials you configure. Once connected, you can specify the table you want to work with and choose how to interact with the data, such as writing SQL queries or setting filters. The component securely executes your instructions and returns the results, which you can use in later steps of your workflow. It handles the connection and execution details behind the scenes, providing a simple interface for managing your data.
Connection & Credentials
This component requires configuring a credential in the Nappai panel before interacting with the external service:
- Go to the Credentials section in your Nappai panel.
- Create a new credential of the type libSQL / Turso and fill in the required fields (URL and Token).
- In your workflow, select the saved credential in the Credential input field of this node.
Inputs
Input Fields
The following fields are available to configure this component. Each field may be visible in different operations:
- Operation: Selects the specific action you want to perform on the database.
- Table Name: The name of the database table you want to access or modify.
- Custom Query: Write your SQL query here. Examples:
SELECT * FROM users WHERE age > 25,UPDATE products SET price = 100 WHERE id = 5,INSERT INTO customers (name, email) VALUES ('John', 'john@email.com'). You can write multiple lines for complex queries. - Select Filter Type: Choose how to build your search conditions. String Mode is recommended for simple filters, allowing you to write conditions in a natural SQL-like style. Build Manually Mode is available for advanced visual form-based filters.
- Filter String: Define search conditions to filter records. Examples:
age > 25returns records older than 25.name = 'Anna' AND city = 'Madrid'returns Annas from Madrid. Rules: Text should be in single quotes, numbers without quotes, booleans as true/false lowercase. UseAND/ORto combine conditions. - Return All: Determine whether to return all matching results or only up to a specific limit.
- Number of Results: Specify the number of results to return from the database.
- Limit: Set a limit on the number of results to return.
- Filters: Define the number of filters to decide which rows are retrieved.
- Field to Update: Specify the number of fields to update in the table.
- Mode: Select how to insert data: Dynamic (use table columns) or Custom (use ingest data).
- Ingest Data: Provide the data to be inserted into the database table.
Outputs
- Data: Returns the records or results retrieved from your database. This output contains the actual data found based on your query or filters, which you can pass to other components for further processing, display, or sending.
- Database Info: Provides metadata or status information about the database connection or the operation performed. This can include details about the database structure or confirmation of successful actions.
Output Data Example (JSON)
json [ { “id”: 1, “name”: “Alice”, “email”: “alice@example.com”, “status”: “active” }, { “id”: 2, “name”: “Bob”, “email”: “bob@example.com”, “status”: “pending” } ]
Connectivity
- Outputs: The
Dataoutput is typically connected to components that process, display, or send the retrieved records, such as API Response, Email, or Visualization nodes. TheDatabase Infooutput can be connected to logging components or used in conditional branches to verify the status of the database interaction. - Inputs: This component is usually placed after a trigger or data preparation node. The
Table NameandCustom Queryinputs depend on knowing which data source you are working with, whileFilter StringandModeinputs allow you to customize how the data is retrieved or inserted.
Usage Example
Imagine you want to retrieve a list of active users from your Turso database and send them a newsletter. You would configure the libSQL node to select the users table, write a filter string like status = 'active', and set the Return All flag to true. Connect the Data output to an Email node to send the newsletter to each user.
Tips and Best Practices
- Always verify your database URL and Token are correct in the credential configuration.
- Use the
Filter Stringfor simple lookups to save time instead of writing full queries. - Set a
Limiton results when retrieving large datasets to improve performance. - Check the
Dataoutput to ensure records were returned before passing them to downstream components. - Use the
Modeoption to easily select whether to insert data dynamically based on columns or using custom ingest data.
Security Considerations
- Ensure your libSQL / Turso credentials are stored securely in the Nappai panel and not shared publicly.
- When using
Custom Query, be mindful of the data structure to avoid errors in downstream components. - Regularly review access permissions in your Turso database to follow the principle of least privilege.