Package Information
Available Nodes
Documentation generating…
Documentation
n8n Persistent Variables Node
A community node for n8n that allows you to store and retrieve persistent variables in a SQLite database. These variables can be shared across multiple workflows and persist between n8n restarts.
Features
- Set Variable: Store a variable with a name and value
- Get Variable: Retrieve a variable value by name
- SQLite Storage: Variables are stored in a local SQLite database
- Persistent: Variables persist between n8n restarts
- Cross-Workflow: Variables can be accessed from any workflow
Installation
Using n8n UI (Recommended)
Open your n8n instance and go to Settings → Community Nodes
Click "Install a community node"
Enter the package name:
n8n-nodes-persistent-variablesClick "Install" and wait for the installation to complete
Restart n8n if prompted
Find the node in the node panel under the "Transform" category
Manual Installation (Advanced Users)
If you prefer manual installation or are developing the node:
# Clone the repository
git clone https://github.com/StancuFlorin/n8n-nodes-persistent-variables.git
cd n8n-nodes-persistent-variables
# Install dependencies
npm install
# Build the node
npm run build
# Copy to your n8n custom nodes directory
cp -r nodes /path/to/your/n8n/custom/nodes/
Usage
Setting a Variable
- Add the "Global Variables" node to your workflow
- Set the operation to "Set Variable"
- Enter the variable name (e.g., "apiKey")
- Enter the variable value (e.g., "your-api-key-here")
- Optionally specify a custom database path (default: ./global_variables.db)
Getting a Variable
- Add the "Global Variables" node to your workflow
- Set the operation to "Get Variable"
- Enter the variable name to retrieve
- Optionally specify a custom database path (default: ./global_variables.db)
Node Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| Operation | Options | Yes | Choose between "Set Variable" or "Get Variable" |
| Variable Name | String | Yes | Name of the variable to set or get |
| Variable Value | String | No | Value to set (only for Set operation) |
| Database Path | String | Yes | Path to the SQLite database file |
Output Format
Set Variable Output
{
"operation": "set",
"variableName": "myVariable",
"result": {
"message": "Variable 'myVariable' set successfully",
"name": "myVariable",
"value": "myValue",
"changes": 1
},
"success": true
}
Get Variable Output
{
"operation": "get",
"variableName": "myVariable",
"result": {
"message": "Variable 'myVariable' retrieved successfully",
"name": "myVariable",
"value": "myValue",
"created_at": "2024-01-01 12:00:00",
"updated_at": "2024-01-01 12:00:00",
"exists": true
},
"success": true
}
Use Cases
- Configuration Management: Store API keys, endpoints, or other configuration values
- Data Caching: Cache expensive computation results between workflow runs
- State Management: Maintain state information across different workflows
- User Preferences: Store user-specific settings or preferences
- Cross-Workflow Communication: Share data between different workflows
Database Schema
The node creates a SQLite table with the following structure:
CREATE TABLE global_variables (
name TEXT PRIMARY KEY,
value TEXT NOT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
Development
Prerequisites
- Node.js 16+
- npm or yarn
- TypeScript
Building
# Install dependencies
npm install
# Build the project
npm run build
# Watch for changes during development
npm run dev
Linting
# Run linter
npm run lint
# Fix linting issues
npm run lintfix
Testing
The node includes error handling and will return error information in the output if something goes wrong. You can test the node by:
- Setting a variable with the "Set Variable" operation
- Retrieving the same variable with the "Get Variable" operation
- Checking the output to ensure the values match
Error Handling
The node includes comprehensive error handling:
- Database connection errors
- SQL execution errors
- Missing variable errors (for Get operation)
- File system errors (database path issues)
Errors are returned in the output with success: false and an error message.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
MIT License - see LICENSE file for details.
Support
For issues and feature requests, please use the GitHub issue tracker.
Changelog
1.0.0
- Initial release
- Set and Get variable operations
- SQLite database storage
- Cross-workflow variable sharing