Mira Library Execute
AI-generatedOverview
The "Mira Library Execute" node allows users to perform SQL operations (INSERT, UPDATE, DELETE) or execute custom SQL statements on a specific Mira library database. It is designed for scenarios where you need to manipulate records directly within a Mira-managed SQLite database, such as adding new files, updating metadata, deleting entries, or running arbitrary SQL commands.
Practical examples include:
- Inserting new file records into the library with details like name, path, and size.
- Updating existing records to modify tags or other attributes.
- Deleting obsolete records based on certain conditions.
- Running complex queries or batch updates using custom SQL.
This node is beneficial in workflows that require direct database manipulation without needing separate database management tools.
Properties
| Name | Meaning |
|---|---|
| Token Source | Choose where to get the access token from: "From Credentials" (use stored API credentials) or "From Input Data" (provide token dynamically). |
| Server URL | The URL of the Mira App Server (required if token source is "From Input Data"). |
| Access Token | Access token string used for authentication when token source is "From Input Data". |
| Library ID | ID of the Mira library database to operate on (e.g., "library-123"). |
| Operation Type | Type of SQL operation to perform: INSERT, UPDATE, DELETE, or Custom SQL statement. |
| SQL Statement | The actual SQLite SQL statement to execute on the library database. |
| Parameters | Optional JSON array of parameters to bind to the SQL statement placeholders. |
Output
The node outputs JSON data containing the result of the SQL execution with the following fields:
operationType: The type of operation performed (insert, update, delete, or custom).affectedRows: Number of rows affected by the operation (from thechangesproperty returned by the database).insertId: The ID of the last inserted row if applicable (from thelastIDproperty).timestamp: ISO timestamp indicating when the operation was executed.
If the node supports binary data output, it is not indicated in the code; thus, only JSON output is relevant here.
Dependencies
- Requires an active connection to a Mira App Server accessible via HTTP.
- Needs an access token for authentication, either provided via stored credentials or input data.
- The node depends on Mira's REST API endpoint
/api/libraries/{libraryId}/executeto run SQL commands. - No additional external services are required beyond the Mira server and valid authentication.
Troubleshooting
Common Issues:
- Invalid or missing Library ID will cause the request to fail.
- Incorrect SQL statement syntax or mismatched operation type and SQL command (e.g., using an UPDATE statement with the INSERT operation) will throw validation errors.
- Malformed JSON in the Parameters field will cause parsing errors.
Error Messages:
"SQL statement must start with INSERT for insert operations"(or similar for UPDATE/DELETE): Ensure the SQL statement matches the selected operation type."Invalid JSON format for parameters: ...": Check that the Parameters field contains a valid JSON array."Parameters must be a JSON array": The parameters must be an array, not an object or other JSON type.
Resolution Tips:
- Double-check the SQL statement syntax and ensure it aligns with the chosen operation.
- Validate JSON formatting of parameters before saving.
- Confirm the Library ID is correct and the Mira server is reachable.
Links and References
- Mira App Server API documentation (for executing SQL on libraries) — consult your Mira platform docs.
- SQLite SQL syntax reference: https://www.sqlite.org/lang.html
- n8n documentation on creating and using custom nodes: https://docs.n8n.io/integrations/creating-nodes/