DB-Client-Node
简体中文 | English
DB-Client-Node is a plugin tool designed for Dify workflows, providing database operation nodes. It currently supports PostgreSQL databases.
Features
- Securely manages database connection information through Dify’s mechanism.
- Supports parameterized execution of DML statements such as and .
- Provides dynamic SQL generation with conditional logic support.
- Implements performance-optimized batch data insertion.
Installation
To use in a Dify workflow:
- Install the plugin via the Dify plugin marketplace or manually download version from the release page.
- Configure PostgreSQL credentials in Dify’s settings.
Nodes Overview
Standard Client Nodes
Standard client nodes are used to execute DML statements such as and . Due to limitations in Dify’s tool plugin form interface, which does not support dynamic parameters, two variants are provided:
- : Supports up to 5 SQL parameters.
- : Supports up to 10 SQL parameters.
These nodes are identical except for the number of supported parameters.
Usage Examples
-
Executing SQL Without Parameters
-
Executing SQL With Parameters
-
Executing Dynamic SQL
- The syntax uses Jinja2 templating to enable dynamic SQL. If the condition (e.g., ) is not met, that portion is excluded from the executed SQL; otherwise, it is included.
Batch Client Node
The batch client node is designed for bulk data insertion, utilizing the database’s batch submission mechanism to reduce I/O overhead and latency.
Usage Example
Node Output
Query Execution
For statements, the node provides the following return values:
- : The query result data, represented as a list of rows where each row is an array of column values.
- : A list of column names corresponding to the result set.
- : An alternative representation of the query result data in the default return format of the plugin tool, structured as an object with column names as keys.
Example Output:
Update Execution
For , , or statements, the node returns:
- : The number of rows affected.
Example Output:
Limitations
- Currently supports only PostgreSQL databases.
- The number of parameters in standard client nodes is fixed (5 or 10), limited by Dify’s form interface.
- Dynamic SQL relies on Jinja2 syntax, which may require familiarity with templating.
Contribution Guidelines
Contributions are welcome! To participate:
- Fork this repository.
- Create a feature branch ().
- Commit your changes ().
- Push to the branch ().
- Submit a Pull Request.
Please ensure your code adheres to the project’s style guidelines and includes appropriate tests.
License
This project is released under the Apache License 2.0. See the file for details.
Contact
For questions or support, please submit an issue in the repository.