diff --git a/README.md b/README.md index e9b7bd84..91b42eef 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ OceanBase is a high-performance database compatible with both MySQL and Oracle p | [OceanBase SQL Helper Plugin](./oceanbase-sql-helper-plugin/README.md) | Development Tools | VSCode extension for quick access to OceanBase SQL keywords documentation | | [Metabase OceanBase Plugin](./metabase-oceanbase-plugin/README.md) | Data Visualization | Enables Metabase to connect to OceanBase (MySQL/Oracle mode) | | [OceanBase SQLAlchemy Plugin](./oceanbase-sqlalchemy-plugin/README.md) | Python ORM | SQLAlchemy dialect for OceanBase Oracle mode, compatible with SQLAlchemy 1.3+ and 2.0+ | -| [OceanBase Dify Plugin](./oceanbase-dify-plugins/README.md) | AI Applications | Enables secure SQL query execution on OceanBase databases through Dify applications | +| [OceanBase Dify Plugin](./dify-plugin-oceanbase/README.md) | AI Applications | Enables secure SQL query execution on OceanBase databases through Dify applications | | [LangGraph Checkpoint OceanBase Plugin](./langgraph-checkpoint-oceanbase-plugin/README.md) | LangGraph CheckpointSaver| Implementation of LangGraph CheckpointSaver that uses OceanBase MySQL mode| --- @@ -73,9 +73,10 @@ OceanBase is a high-performance database compatible with both MySQL and Oracle p ### ✅ OceanBase Dify Plugin -- **Function**: A simple OceanBase database plugin that enables secure SQL query execution on OceanBase databases through Dify applications with comprehensive error handling and result formatting. +- **Function**: A Dify plugin for connecting to and querying OceanBase databases. This project has been migrated to a new repository. - **Use Case**: AI applications that need to interact with OceanBase databases through Dify platform for data querying and manipulation. -- **Documentation**: [OceanBase Dify Plugin](./oceanbase-dify-plugins/README.md) +- **Documentation**: [OceanBase Dify Plugin](./dify-plugin-oceanbase/README.md) +- **New Repository**: https://github.com/oceanbase/dify-plugin-oceanbase --- @@ -99,7 +100,7 @@ OceanBase is a high-performance database compatible with both MySQL and Oracle p | OceanBase SQL Helper Plugin | [OceanBase SQL Helper Plugin](./oceanbase-sql-helper-plugin/README.md) | | Metabase OceanBase Plugin | [Metabase OceanBase Plugin](./metabase-oceanbase-plugin/README.md) | | OceanBase SQLAlchemy Plugin | [OceanBase SQLAlchemy Plugin](./oceanbase-sqlalchemy-plugin/README.md) | -| OceanBase Dify Plugin | [OceanBase Dify Plugin](./oceanbase-dify-plugins/README.md) | +| OceanBase Dify Plugin | [OceanBase Dify Plugin](./dify-plugin-oceanbase/README.md) | | LangGraph Checkpoint OceanBase Plugin | [LangGraph Checkpoint OceanBase Plugin](./langgraph-checkpoint-oceanbase-plugin/README.md) | --- diff --git a/README_CN.md b/README_CN.md index 317bcdda..de2eb5f2 100644 --- a/README_CN.md +++ b/README_CN.md @@ -19,7 +19,7 @@ OceanBase 是一款兼容 MySQL 和 Oracle 协议的高性能数据库。本仓 | [Metabase OceanBase 插件](./metabase-oceanbase-plugin/README_CN.md) | 数据可视化 | 支持 Metabase 连接 OceanBase(MySQL/Oracle 模式) | | [OceanBase SQLAlchemy 插件](./oceanbase-sqlalchemy-plugin/README.md) | Python ORM | SQLAlchemy 方言,支持 OceanBase Oracle 模式,兼容 SQLAlchemy 1.3+ 和 2.0+ | | [LangGraph Checkpoint OceanBase 插件](./langgraph-checkpoint-oceanbase-plugin/README.md) | 保存 LangGraph 的 checkpoint | 使用 OceanBase MySQL 模式实现了 LangGraph CheckpointSaver | -| [OceanBase Dify 插件](./oceanbase-dify-plugins/README_CN.md) | AI 应用 | 通过 Dify 应用程序在 OceanBase 数据库上安全执行 SQL 查询 | +| [OceanBase Dify 插件](./dify-plugin-oceanbase/README_CN.md) | AI 应用 | 通过 Dify 应用程序在 OceanBase 数据库上安全执行 SQL 查询 | | [LangGraph Checkpoint OceanBase 插件](./langgraph-checkpoint-oceanbase-plugin/README_CN.md) | 保存 LangGraph 的 checkpoint | 使用 OceanBase MySQL 模式实现了 LangGraph CheckpointSaver | ------ @@ -83,9 +83,10 @@ OceanBase 是一款兼容 MySQL 和 Oracle 协议的高性能数据库。本仓 ### ✅ OceanBase Dify 插件 -- **功能**:一个简单的 OceanBase 数据库插件,通过 Dify 应用程序在 OceanBase 数据库上安全执行 SQL 查询,具有全面的错误处理和结果格式化功能。 +- **功能**:用于连接和查询 OceanBase 数据库的 Dify 插件。此项目已迁移到新仓库。 - **适用场景**:需要通过 Dify 平台与 OceanBase 数据库交互进行数据查询和操作的 AI 应用程序。 -- **详细文档**:[OceanBase Dify 插件](./oceanbase-dify-plugins/README_CN.md) +- **详细文档**:[OceanBase Dify 插件](./dify-plugin-oceanbase/README_CN.md) +- **新仓库地址**:https://github.com/oceanbase/dify-plugin-oceanbase ------ @@ -109,7 +110,7 @@ OceanBase 是一款兼容 MySQL 和 Oracle 协议的高性能数据库。本仓 | Metabase OceanBase 插件 | [Metabase OceanBase 插件](./metabase-oceanbase-plugin/README_CN.md) | | OceanBase SQLAlchemy 插件 | [OceanBase SQLAlchemy 插件](./oceanbase-sqlalchemy-plugin/README.md) | | LangGraph Checkpoint OceanBase 插件 | [LangGraph Checkpoint OceanBase 插件](./langgraph-checkpoint-oceanbase-plugin/README.md) | -| OceanBase Dify 插件 | [OceanBase Dify 插件](./oceanbase-dify-plugins/README_CN.md) | +| OceanBase Dify 插件 | [OceanBase Dify 插件](./dify-plugin-oceanbase/README_CN.md) | | LangGraph Checkpoint OceanBase 插件 | [LangGraph Checkpoint OceanBase 插件](./langgraph-checkpoint-oceanbase-plugin/README_CN.md) | ------ diff --git a/dify-plugin-oceanbase/README.md b/dify-plugin-oceanbase/README.md new file mode 100644 index 00000000..fea02134 --- /dev/null +++ b/dify-plugin-oceanbase/README.md @@ -0,0 +1,61 @@ +# OceanBase Dify Plugin + +> **Note**: This project has been migrated to a new repository. Please use the new repository address. + +## 🔗 Repository Address + +**GitHub**: https://github.com/oceanbase/dify-plugin-oceanbase + +## 📖 Project Description + +This is a Dify plugin for connecting to and querying OceanBase databases. + +## 🌟 Features + +### Tools Introduction + +#### 1. Execute SQL + +- **Function**: Execute SQL queries on existing OceanBase databases +- **Usage**: Directly execute SQL statements starting with SELECT, SHOW, or WITH +- **Output Format**: Supports multiple formats including JSON, CSV, YAML, Markdown, Excel, HTML, etc. +- **Security Restrictions**: Only supports query statements to ensure database security + +#### 2. Get Table Schema + +- **Function**: Get table structure information from the database +- **Usage**: Provide database context for LLM to help understand table structure +- **Flexibility**: Can specify specific tables or get structure information for all tables +- **Use Cases**: Understand database structure before generating SQL queries + +#### 3. Text to SQL + +- **Function**: Use LLM to convert natural language queries into SQL statements +- **Usage**: Allow users to describe query requirements in natural language and automatically generate corresponding SQL +- **Intelligence**: Generate accurate SQL based on database context and table structure information +- **Model Selection**: Support selecting different large language models for conversion + +## 🚀 Usage Instructions + +1. **Database Connection**: Configure OceanBase database connection information +2. **Select Tools**: Choose appropriate tools based on requirements +3. **Execute Queries**: Query data through natural language or direct SQL +4. **Get Results**: Obtain query results in specified format + +## ⚠️ Notes + +- This plugin only supports query operations and does not support data modification +- It is recommended to use read-only database accounts to ensure security +- Supports multiple output formats that can be selected as needed + +## 📝 License + +This project is licensed under the Apache-2.0 License. + +## 🤝 Contributing + +Please visit the repository to contribute: https://github.com/oceanbase/dify-plugin-oceanbase + +## 📞 Support + +For issues and questions, please submit an Issue in the repository: https://github.com/oceanbase/dify-plugin-oceanbase/issues \ No newline at end of file diff --git a/dify-plugin-oceanbase/README_CN.md b/dify-plugin-oceanbase/README_CN.md new file mode 100644 index 00000000..88b20b68 --- /dev/null +++ b/dify-plugin-oceanbase/README_CN.md @@ -0,0 +1,61 @@ +# OceanBase Dify 插件 + +> **注意**: 此项目已迁移到新的仓库。请使用新的仓库地址。 + +## 🔗 仓库地址 + +**GitHub**: https://github.com/oceanbase/dify-plugin-oceanbase + +## 📖 项目描述 + +这是一个用于连接和查询 OceanBase 数据库的 Dify 插件。 + +## 🌟 功能特性 + +### 工具介绍 + +#### 1. 执行 SQL + +- **功能**: 在现有 OceanBase 数据库上执行 SQL 查询 +- **用法**: 直接执行以 SELECT、SHOW 或 WITH 开头的 SQL 语句 +- **输出格式**: 支持多种格式,包括 JSON、CSV、YAML、Markdown、Excel、HTML 等 +- **安全限制**: 仅支持查询语句,确保数据库安全 + +#### 2. 获取表结构 + +- **功能**: 从数据库获取表结构信息 +- **用法**: 为 LLM 提供数据库上下文,帮助理解表结构 +- **灵活性**: 可以指定特定表或获取所有表的结构信息 +- **用例**: 在生成 SQL 查询前了解数据库结构 + +#### 3. 文本转 SQL + +- **功能**: 使用 LLM 将自然语言查询转换为 SQL 语句 +- **用法**: 允许用户用自然语言描述查询需求,自动生成相应的 SQL +- **智能性**: 基于数据库上下文和表结构信息生成准确的 SQL +- **模型选择**: 支持选择不同的大语言模型进行转换 + +## 🚀 使用说明 + +1. **数据库连接**: 配置 OceanBase 数据库连接信息 +2. **选择工具**: 根据需求选择合适的工具 +3. **执行查询**: 通过自然语言或直接 SQL 查询数据 +4. **获取结果**: 以指定格式获取查询结果 + +## ⚠️ 注意事项 + +- 此插件仅支持查询操作,不支持数据修改 +- 建议使用只读数据库账户以确保安全 +- 支持多种输出格式,可根据需要选择 + +## 📝 许可证 + +本项目采用 Apache-2.0 许可证。 + +## 🤝 贡献 + +请访问仓库进行贡献:https://github.com/oceanbase/dify-plugin-oceanbase + +## 📞 支持 + +如有问题,请在新仓库中提交 Issue:https://github.com/oceanbase/dify-plugin-oceanbase/issues diff --git a/oceanbase-dify-plugins/.github/workflows/plugin-publish.yml b/oceanbase-dify-plugins/.github/workflows/plugin-publish.yml deleted file mode 100644 index 3462f869..00000000 --- a/oceanbase-dify-plugins/.github/workflows/plugin-publish.yml +++ /dev/null @@ -1,143 +0,0 @@ -# .github/workflows/plugin-publish.yml -name: Auto Create PR on Main Push - -on: - push: - branches: [ main ] # Trigger on push to main - -jobs: - create_pr: # Renamed job for clarity - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Print working directory # Kept for debugging - run: | - pwd - ls -la - - - name: Download CLI tool - run: | - # Create bin directory in runner temp - mkdir -p $RUNNER_TEMP/bin - cd $RUNNER_TEMP/bin - - # Download CLI tool - wget https://github.com/langgenius/dify-plugin-daemon/releases/download/0.0.6/dify-plugin-linux-amd64 - chmod +x dify-plugin-linux-amd64 - - # Show download location and file - echo "CLI tool location:" - pwd - ls -la dify-plugin-linux-amd64 - - - name: Get basic info from manifest # Changed step name and content - id: get_basic_info - run: | - PLUGIN_NAME=$(grep "^name:" manifest.yaml | cut -d' ' -f2) - echo "Plugin name: $PLUGIN_NAME" - echo "plugin_name=$PLUGIN_NAME" >> $GITHUB_OUTPUT - - VERSION=$(grep "^version:" manifest.yaml | cut -d' ' -f2) - echo "Plugin version: $VERSION" - echo "version=$VERSION" >> $GITHUB_OUTPUT - - # If the author's name is not your github username, you can change the author here - AUTHOR=$(grep "^author:" manifest.yaml | cut -d' ' -f2) - echo "Plugin author: $AUTHOR" - echo "author=$AUTHOR" >> $GITHUB_OUTPUT - - - name: Package Plugin - id: package - run: | - # Use the downloaded CLI tool to package - cd $GITHUB_WORKSPACE - # Use variables for package name - PACKAGE_NAME="${{ steps.get_basic_info.outputs.plugin_name }}-${{ steps.get_basic_info.outputs.version }}.difypkg" - # Use CLI from runner temp - $RUNNER_TEMP/bin/dify-plugin-linux-amd64 plugin package . -o "$PACKAGE_NAME" - - # Show packaging result - echo "Package result:" - ls -la "$PACKAGE_NAME" - echo "package_name=$PACKAGE_NAME" >> $GITHUB_OUTPUT - - # Show full file path and directory structure (kept for debugging) - echo "\\nFull file path:" - pwd - echo "\\nDirectory structure:" - tree || ls -R - - - name: Checkout target repo - uses: actions/checkout@v3 - with: - # Use author variable for repository - repository: ${{steps.get_basic_info.outputs.author}}/dify-plugins - path: dify-plugins - token: ${{ secrets.PLUGIN_ACTION }} - fetch-depth: 1 # Fetch only the last commit to speed up checkout - persist-credentials: true # Persist credentials for subsequent git operations - - - name: Prepare and create PR - run: | - # Debug info (kept) - echo "Debug: Current directory $(pwd)" - # Use variable for package name - PACKAGE_NAME="${{ steps.get_basic_info.outputs.plugin_name }}-${{ steps.get_basic_info.outputs.version }}.difypkg" - echo "Debug: Package name: $PACKAGE_NAME" - ls -la - - # Move the packaged file to the target directory using variables - mkdir -p dify-plugins/${{ steps.get_basic_info.outputs.author }}/${{ steps.get_basic_info.outputs.plugin_name }} - mv "$PACKAGE_NAME" dify-plugins/${{ steps.get_basic_info.outputs.author }}/${{ steps.get_basic_info.outputs.plugin_name }}/ - - # Enter the target repository directory - cd dify-plugins - - # Configure git - git config user.name "GitHub Actions" - git config user.email "actions@github.com" - - # Ensure we are on the latest main branch - git fetch origin main - git checkout main - git pull origin main - - # Create and switch to a new branch using variables and new naming convention - BRANCH_NAME="bump-${{ steps.get_basic_info.outputs.plugin_name }}-plugin-${{ steps.get_basic_info.outputs.version }}" - git checkout -b "$BRANCH_NAME" - - # Add and commit changes (using git add .) - git add . - git status # for debugging - # Use variables in commit message - git commit -m "bump ${{ steps.get_basic_info.outputs.plugin_name }} plugin to version ${{ steps.get_basic_info.outputs.version }}" - - # Push to remote (use force just in case the branch existed before from a failed run) - git push -u origin "$BRANCH_NAME" --force - - # Confirm branch has been pushed and wait for sync (GitHub API might need a moment) - git branch -a - echo "Waiting for branch to sync..." - sleep 10 # Wait 10 seconds for branch sync - - - name: Create PR via GitHub API - env: - GH_TOKEN: ${{ secrets.PLUGIN_ACTION }} # Use the provided token for authentication - run: | - gh pr create \ - --repo langgenius/dify-plugins \ - --head "${{ steps.get_basic_info.outputs.author }}:${{ steps.get_basic_info.outputs.plugin_name }}-${{ steps.get_basic_info.outputs.version }}" \ - --base main \ - --title "bump ${{ steps.get_basic_info.outputs.plugin_name }} plugin to version ${{ steps.get_basic_info.outputs.version }}" \ - --body "bump ${{ steps.get_basic_info.outputs.plugin_name }} plugin package to version ${{ steps.get_basic_info.outputs.version }} - - Changes: - - Updated plugin package file" || echo "PR already exists or creation skipped." # Handle cases where PR already exists - - - name: Print environment info # Kept for debugging - run: | - echo "GITHUB_WORKSPACE: $GITHUB_WORKSPACE" - echo "Current directory contents:" - ls -R diff --git a/oceanbase-dify-plugins/.gitignore b/oceanbase-dify-plugins/.gitignore deleted file mode 100644 index 85e39d94..00000000 --- a/oceanbase-dify-plugins/.gitignore +++ /dev/null @@ -1,50 +0,0 @@ -# Python -__pycache__/ -*.py[cod] -*$py.class - -# Virtual environments -venv/ -env/ -*.venv - -# IDE -.vscode/ -.idea/ -*.swp -*.swo -*~ - -# OS -.DS_Store -Thumbs.db - -# Logs -logs/ -*.log - -# Dependencies -# requirements.txt - -# Build -/dist/ -/build/ -*.egg-info/ - -# Environment variables -.env -.env.* -.env.local -.env.development.local -.env.test.local -.env.production.local - -# Test -coverage/ -.coverage -.pytest_cache/ - -# Temporary files -*.tmp -*.temp -.cache/ \ No newline at end of file diff --git a/oceanbase-dify-plugins/LICENSE b/oceanbase-dify-plugins/LICENSE deleted file mode 100644 index 261eeb9e..00000000 --- a/oceanbase-dify-plugins/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/oceanbase-dify-plugins/PRIVACY.md b/oceanbase-dify-plugins/PRIVACY.md deleted file mode 100644 index f919e0cf..00000000 --- a/oceanbase-dify-plugins/PRIVACY.md +++ /dev/null @@ -1,45 +0,0 @@ -# Privacy Policy - -## Data Collection and Usage - -This OceanBase Database Tools plugin for Dify is designed with privacy and security in mind. Here's how we handle your data: - -### What We Collect -- **Database Connection Information**: Host, port, username, password, and database name (stored securely in Dify's credential management system) -- **SQL Queries**: The SQL statements you execute through the plugin -- **Search Keywords**: Keywords used for documentation search - -### What We Don't Collect -- **Personal Data**: We do not collect any personal information -- **Query Results**: Database query results are not stored or transmitted to external services -- **Usage Analytics**: We do not track your usage patterns - -### Data Processing -- **Local Processing**: All database operations are performed locally within your Dify environment -- **No External Transmission**: Database credentials and query results are never transmitted to external services -- **Secure Storage**: Credentials are stored using Dify's secure credential management system - -### Third-Party Services -- **OceanBase Documentation Search**: When using the documentation search feature, search keywords are sent to OceanBase's official documentation API -- **No Other Third Parties**: We do not share data with any other third-party services - -### Data Retention -- **No Persistent Storage**: We do not store any data beyond the duration of your active session -- **Immediate Deletion**: All temporary data is deleted immediately after processing - -### Security Measures -- **Encrypted Connections**: All database connections use encrypted protocols -- **Credential Protection**: Database credentials are handled securely through Dify's credential system -- **Input Validation**: All inputs are validated to prevent security vulnerabilities - -### Your Rights -- **Access**: You can access your plugin configuration through Dify's interface -- **Deletion**: You can remove the plugin and its configuration at any time -- **Control**: You have full control over what data you provide to the plugin - -### Contact -If you have any questions about this privacy policy, please contact us through the plugin's GitHub repository. - ---- - -**Last Updated**: September 1, 2025 \ No newline at end of file diff --git a/oceanbase-dify-plugins/README.md b/oceanbase-dify-plugins/README.md deleted file mode 100644 index 26ed8e20..00000000 --- a/oceanbase-dify-plugins/README.md +++ /dev/null @@ -1,118 +0,0 @@ -# OceanBase Database Tools for Dify - -A simple OceanBase database plugin that enables secure SQL query execution on OceanBase databases through Dify applications. - -## 🌟 Features - -### Database Operations -- **Execute SQL Statements**: Run any SQL command including SELECT, INSERT, UPDATE, DELETE, SHOW, DESCRIBE, CALL, etc. -- **Smart Result Formatting**: Automatically formats query results for better readability -- **Comprehensive Error Handling**: Provides detailed error messages for troubleshooting - -## 🚀 Quick Start - -### 1. Installation -1. Install the plugin in your Dify environment -2. Configure your OceanBase connection credentials -3. Start using the SQL execution tool in your Dify applications - -### 2. Configuration -Configure the following connection parameters: - -| Parameter | Type | Required | Default | Description | -|-----------|------|----------|---------|-------------| -| ob_host | text-input | Yes | localhost | OceanBase server address | -| ob_port | text-input | Yes | 2881 | OceanBase service port | -| ob_user | text-input | Yes | - | Database username | -| ob_password | secret-input | Yes | - | Database password | -| ob_database | text-input | Yes | - | Database name | - -### 3. Usage Examples - -#### Execute SQL Query -``` -Execute SQL: SELECT * FROM users LIMIT 10 -``` - -#### Show Tables -``` -Execute SQL: SHOW TABLES -``` - -#### Describe Table Structure -``` -Execute SQL: DESCRIBE users -``` - -#### Insert Data -``` -Execute SQL: INSERT INTO users (name, email) VALUES ('John', 'john@example.com') -``` - -## 🛠️ Available Tools - -### Execute SQL -Execute SQL statements on OceanBase database with comprehensive error handling and result formatting. - -**Parameters:** -- `sql` (string, required): The SQL statement to execute - -**Supported SQL Types:** -- SELECT queries with formatted results -- INSERT, UPDATE, DELETE operations -- SHOW commands (TABLES, COLUMNS, etc.) -- DESCRIBE table structure -- CALL stored procedures -- CREATE, ALTER, DROP DDL statements - -## 🔧 Development - -### Project Structure -``` -oceanbase-dify-plugins/ -├── main.py # Plugin entry point -├── manifest.yaml # Plugin metadata -├── requirements.txt # Python dependencies -├── provider/ -│ ├── oceanbase-dify-plugins.yaml # Provider configuration -│ └── oceanbase-dify-plugins.py # Provider implementation -└── tools/ - ├── execute_sql.yaml # SQL execution tool config - └── execute_sql.py # SQL execution tool implementation -``` - -### Local Development -1. Clone the repository -2. Install dependencies: `pip install -r requirements.txt` -3. Configure environment variables -4. Run locally: `python -m main` - -## 🔒 Security - -- All database credentials are securely stored and encrypted -- SQL injection protection through parameterized queries -- Connection validation before tool execution -- No sensitive data logging - -## 📝 License - -This project is licensed under the MIT License - see the LICENSE file for details. - -## 🤝 Contributing - -1. Fork the repository -2. Create a feature branch -3. Make your changes -4. Add tests if applicable -5. Submit a pull request - -## 📞 Support - -For issues and questions: -- Check the documentation -- Review the troubleshooting guide - -## 🔗 Related Projects - -- OceanBase MCP Server - The underlying MCP server implementation -- Dify Plugin SDK - Dify plugin development framework \ No newline at end of file diff --git a/oceanbase-dify-plugins/README_CN.md b/oceanbase-dify-plugins/README_CN.md deleted file mode 100644 index 58b1c4c3..00000000 --- a/oceanbase-dify-plugins/README_CN.md +++ /dev/null @@ -1,118 +0,0 @@ -# OceanBase 数据库 Dify 工具 - -一个简单的 OceanBase 数据库插件,通过 Dify 应用程序在 OceanBase 数据库上安全执行 SQL 查询。 - -## 🌟 功能特性 - -### 数据库操作 -- **执行 SQL 语句**:运行任何 SQL 命令,包括 SELECT、INSERT、UPDATE、DELETE、SHOW、DESCRIBE、CALL 等 -- **智能结果格式化**:自动格式化查询结果,提高可读性 -- **全面的错误处理**:提供详细的错误信息,便于故障排除 - -## 🚀 快速开始 - -### 1. 安装 -1. 在您的 Dify 环境中安装插件 -2. 配置您的 OceanBase 连接凭据 -3. 开始在您的 Dify 应用程序中使用 SQL 执行工具 - -### 2. 配置 -配置以下连接参数: - -| 参数 | 类型 | 必需 | 默认值 | 描述 | -|------|------|------|--------|------| -| ob_host | text-input | 是 | localhost | OceanBase 服务器地址 | -| ob_port | text-input | 是 | 2881 | OceanBase 服务端口 | -| ob_user | text-input | 是 | - | 数据库用户名 | -| ob_password | secret-input | 是 | - | 数据库密码 | -| ob_database | text-input | 是 | - | 数据库名称 | - -### 3. 使用示例 - -#### 执行 SQL 查询 -``` -执行 SQL:SELECT * FROM users LIMIT 10 -``` - -#### 显示表 -``` -执行 SQL:SHOW TABLES -``` - -#### 描述表结构 -``` -执行 SQL:DESCRIBE users -``` - -#### 插入数据 -``` -执行 SQL:INSERT INTO users (name, email) VALUES ('John', 'john@example.com') -``` - -## 🛠️ 可用工具 - -### 执行 SQL -在 OceanBase 数据库上执行 SQL 语句,具有全面的错误处理和结果格式化功能。 - -**参数:** -- `sql`(字符串,必需):要执行的 SQL 语句 - -**支持的 SQL 类型:** -- 带格式化结果的 SELECT 查询 -- INSERT、UPDATE、DELETE 操作 -- SHOW 命令(TABLES、COLUMNS 等) -- DESCRIBE 表结构 -- CALL 存储过程 -- CREATE、ALTER、DROP DDL 语句 - -## 🔧 开发 - -### 项目结构 -``` -oceanbase-dify-plugins/ -├── main.py # 插件入口点 -├── manifest.yaml # 插件元数据 -├── requirements.txt # Python 依赖 -├── provider/ -│ ├── oceanbase-dify-plugins.yaml # 提供者配置 -│ └── oceanbase-dify-plugins.py # 提供者实现 -└── tools/ - ├── execute_sql.yaml # SQL 执行工具配置 - └── execute_sql.py # SQL 执行工具实现 -``` - -### 本地开发 -1. 克隆仓库 -2. 安装依赖:`pip install -r requirements.txt` -3. 配置环境变量 -4. 本地运行:`python -m main` - -## 🔒 安全性 - -- 所有数据库凭据都安全存储并加密 -- 通过参数化查询防止 SQL 注入 -- 工具执行前进行连接验证 -- 不记录敏感数据 - -## 📝 许可证 - -本项目采用 MIT 许可证 - 详情请参阅 LICENSE 文件。 - -## 🤝 贡献 - -1. Fork 仓库 -2. 创建功能分支 -3. 进行更改 -4. 如适用,添加测试 -5. 提交拉取请求 - -## 📞 支持 - -如有问题和疑问: -- 查看文档 -- 查看故障排除指南 - -## 🔗 相关项目 - -- OceanBase MCP Server - 底层 MCP 服务器实现 -- Dify Plugin SDK - Dify 插件开发框架 diff --git a/oceanbase-dify-plugins/_assets/icon.svg b/oceanbase-dify-plugins/_assets/icon.svg deleted file mode 100644 index 2ae4a517..00000000 --- a/oceanbase-dify-plugins/_assets/icon.svg +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/oceanbase-dify-plugins/main.py b/oceanbase-dify-plugins/main.py deleted file mode 100644 index 7f71a1df..00000000 --- a/oceanbase-dify-plugins/main.py +++ /dev/null @@ -1,23 +0,0 @@ -from dify_plugin import Plugin, DifyPluginEnv -import time -import signal -import sys - -def signal_handler(sig, frame): - print('Plugin shutting down...') - sys.exit(0) - -signal.signal(signal.SIGINT, signal_handler) -signal.signal(signal.SIGTERM, signal_handler) - -plugin = Plugin(DifyPluginEnv(MAX_REQUEST_TIMEOUT=120)) - -if __name__ == '__main__': - try: - print('Starting OceanBase plugin...') - plugin.run() - except KeyboardInterrupt: - print('Plugin stopped by user') - except Exception as e: - print(f'Plugin error: {e}') - sys.exit(1) diff --git a/oceanbase-dify-plugins/manifest.yaml b/oceanbase-dify-plugins/manifest.yaml deleted file mode 100644 index feddc0f1..00000000 --- a/oceanbase-dify-plugins/manifest.yaml +++ /dev/null @@ -1,35 +0,0 @@ -version: 0.0.1 -type: plugin -author: xxsc0529 -name: oceanbase_db_plugin -label: - en_US: OceanBase Database Query - ja_JP: OceanBaseデータベース照会 - zh_Hans: OceanBase数据库查询 - pt_BR: Consulta OceanBase Database -description: - en_US: Connect to OceanBase database and execute SQL queries using MySQL protocol. - ja_JP: MySQLプロトコルを使用してOceanBaseデータベースに接続し、SQLクエリを実行します。 - zh_Hans: 使用MySQL协议连接OceanBase数据库并执行SQL查询。 - pt_BR: Conecte-se ao banco de dados OceanBase e execute consultas SQL usando o protocolo MySQL. -icon: icon.svg -icon_dark: icon.svg -resource: - memory: 268435456 - permission: {} -plugins: - tools: - - provider/oceanbase_db_plugin.yaml -meta: - version: 0.0.1 - arch: - - amd64 - - arm64 - runner: - language: python - version: "3.9" - entrypoint: main - minimum_dify_version: "1.3.0" -created_at: 2025-09-23T10:45:00.000000+08:00 -privacy: PRIVACY.md -verified: false \ No newline at end of file diff --git a/oceanbase-dify-plugins/provider/oceanbase_db_plugin.py b/oceanbase-dify-plugins/provider/oceanbase_db_plugin.py deleted file mode 100644 index b8405f5c..00000000 --- a/oceanbase-dify-plugins/provider/oceanbase_db_plugin.py +++ /dev/null @@ -1,27 +0,0 @@ -import logging -from typing import Any - -from dify_plugin import ToolProvider -from dify_plugin.errors.tool import ToolProviderCredentialValidationError - -# Configure logging -logger = logging.getLogger(__name__) - - -class OceanBaseDbPluginProvider(ToolProvider): - def _validate_credentials(self, credentials: dict[str, Any]) -> None: - try: - # Simple validation for required fields only - user = credentials.get('ob_user') - database = credentials.get('ob_database') - - if not user: - raise ValueError("OceanBase username is required") - if not database: - raise ValueError("OceanBase database name is required") - - logger.info(f"Credentials validation passed for user: {user}, database: {database}") - - except Exception as e: - logger.error(f"Credentials validation failed: {str(e)}") - raise ToolProviderCredentialValidationError(str(e)) diff --git a/oceanbase-dify-plugins/provider/oceanbase_db_plugin.yaml b/oceanbase-dify-plugins/provider/oceanbase_db_plugin.yaml deleted file mode 100644 index 34516f89..00000000 --- a/oceanbase-dify-plugins/provider/oceanbase_db_plugin.yaml +++ /dev/null @@ -1,17 +0,0 @@ -identity: - author: xxsc0529 - name: oceanbase_db_plugin - label: - en_US: "OceanBase Database" - zh_Hans: "OceanBase 数据库" - pt_BR: "Banco de Dados OceanBase" - description: - en_US: "Connect to OceanBase database using MySQL protocol" - zh_Hans: "使用MySQL协议连接OceanBase数据库" - pt_BR: "Conectar ao banco de dados OceanBase usando protocolo MySQL" - icon: "icon.svg" -tools: - - tools/oceanbase_db_plugin.yaml -extra: - python: - source: provider/oceanbase_db_plugin.py diff --git a/oceanbase-dify-plugins/requirements.txt b/oceanbase-dify-plugins/requirements.txt deleted file mode 100644 index ca3ab957..00000000 --- a/oceanbase-dify-plugins/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -dify-plugin>=0.2.0 -mysql-connector-python>=8.0.0 \ No newline at end of file diff --git a/oceanbase-dify-plugins/tools/oceanbase_db_plugin.py b/oceanbase-dify-plugins/tools/oceanbase_db_plugin.py deleted file mode 100644 index 2f827815..00000000 --- a/oceanbase-dify-plugins/tools/oceanbase_db_plugin.py +++ /dev/null @@ -1,117 +0,0 @@ -import mysql.connector -from typing import Generator, Any - -from dify_plugin import Tool -from dify_plugin.entities.tool import ToolInvokeMessage - -class OceanBaseDbPluginTool(Tool): - def __init__(self, runtime=None, session=None): - super().__init__(runtime, session) - # 获取当前语言环境,默认为英文 - self.language = self.get_language() - - def get_language(self): - # 从运行环境中获取语言设置,默认返回'en_US' - try: - # 实际应用中可能需要从不同位置获取语言设置 - # 这里仅作为示例 - return 'en_US' - except: - return 'en_US' - - def get_message(self, messages_dict): - # 根据当前语言返回对应消息,如果没有对应语言的消息,返回英文消息 - return messages_dict.get(self.language, messages_dict.get('en_US', '')) - - def _invoke(self, tool_parameters: dict[str, Any]) -> Generator[ToolInvokeMessage, None, None]: - conn = None - try: - # 获取连接参数 - host = tool_parameters.get('host') - port = tool_parameters.get('port', 2881) # 使用默认端口2881 - user = tool_parameters.get('user') - password = tool_parameters.get('password') - database = tool_parameters.get('database') - sql_query = tool_parameters.get('query') - - # 验证必要参数 - if not all([host, user, password, database, sql_query]): - messages = { - 'en_US': 'Missing required parameters: host, user, password, database, query are all required', - 'zh_Hans': '缺少必要参数:host、user、password、database、query都是必需的' - } - yield self.create_json_message({ - "status": "error", - "message": self.get_message(messages) - }) - return - - # 构建连接字符串(隐藏密码) - print(f'Connecting to OceanBase: {host}:{port}/{database}, user: {user}') - - # 连接数据库 - conn = mysql.connector.connect( - host=host, - port=port, - user=user, - password=password, - database=database, - charset='utf8mb4' - ) - print(f'Connected to OceanBase successfully') - - # 创建游标 - with conn.cursor() as cursor: - # 执行查询 - cursor.execute(sql_query) - - # 获取列名 - if cursor.description: - columns = [col[0] for col in cursor.description] - else: - columns = [] - - # 获取查询结果 - results = [] - if cursor.description: - # SELECT查询 - for row in cursor.fetchall(): - # 将每行数据转换为字典 - row_dict = {columns[i]: value for i, value in enumerate(row)} - # 处理可能的特殊类型 - for key, value in row_dict.items(): - # 转换datetime对象为字符串 - if hasattr(value, 'strftime'): - row_dict[key] = value.strftime('%Y-%m-%d %H:%M:%S') - elif value is None: - row_dict[key] = None - results.append(row_dict) - else: - # 非SELECT查询(INSERT, UPDATE, DELETE等) - affected_rows = cursor.rowcount - results = [{"affected_rows": affected_rows}] - - # 返回结果 - messages = { - 'en_US': f'Query executed successfully, returned {len(results)} rows.', - 'zh_Hans': f'查询执行成功,返回了{len(results)}行数据。' - } - yield self.create_json_message({ - "status": "success", - "data": results, - "columns": columns, - "message": self.get_message(messages) - }) - except Exception as e: - # 处理异常并返回错误信息 - yield self.create_json_message({ - "status": "error", - "message": str(e) - }) - finally: - # 确保连接关闭 - if conn: - try: - conn.close() - except: - pass \ No newline at end of file diff --git a/oceanbase-dify-plugins/tools/oceanbase_db_plugin.yaml b/oceanbase-dify-plugins/tools/oceanbase_db_plugin.yaml deleted file mode 100644 index eb6ebe30..00000000 --- a/oceanbase-dify-plugins/tools/oceanbase_db_plugin.yaml +++ /dev/null @@ -1,95 +0,0 @@ -identity: - name: oceanbase_db_plugin - author: xxsc0529 - label: - en_US: "OceanBase Database Query" - zh_Hans: "OceanBase数据库查询" - pt_BR: "Consulta OceanBase Database" -description: - human: - en_US: "Connect to OceanBase database and execute SQL queries using MySQL protocol." - zh_Hans: "使用MySQL协议连接OceanBase数据库并执行SQL查询。" - pt_BR: "Conecte-se ao banco de dados OceanBase e execute consultas SQL usando o protocolo MySQL." - llm: "A tool for connecting to OceanBase database and executing SQL queries using MySQL protocol." -parameters: - - name: host - type: string - required: true - label: - en_US: Database Host - zh_Hans: 数据库主机 - pt_BR: Host do Banco de Dados - human_description: - en_US: "The hostname or IP address of the OceanBase database server." - zh_Hans: "OceanBase数据库服务器的主机名或IP地址。" - pt_BR: "O hostname ou endereço IP do servidor de banco de dados OceanBase." - llm_description: "The hostname or IP address of the OceanBase database server." - form: llm - - name: port - type: number - required: false - label: - en_US: Database Port - zh_Hans: 数据库端口 - pt_BR: Porta do Banco de Dados - human_description: - en_US: "The port number of the OceanBase database server." - zh_Hans: "OceanBase数据库服务器的端口号。" - pt_BR: "O número da porta do servidor de banco de dados OceanBase." - llm_description: "The port number of the OceanBase database server." - form: llm - - name: user - type: string - required: true - label: - en_US: Username - zh_Hans: 用户名 - pt_BR: Nome de Usuário - human_description: - en_US: "The username for connecting to the OceanBase database." - zh_Hans: "连接OceanBase数据库的用户名。" - pt_BR: "O nome de usuário para conectar ao banco de dados OceanBase." - llm_description: "The username for connecting to the OceanBase database." - form: llm - - name: password - type: secret-input - required: true - label: - en_US: Password - zh_Hans: 密码 - pt_BR: Senha - human_description: - en_US: "The password for connecting to the OceanBase database." - zh_Hans: "连接OceanBase数据库的密码。" - pt_BR: "A senha para conectar ao banco de dados OceanBase." - llm_description: "The password for connecting to the OceanBase database." - form: llm - - name: database - type: string - required: true - label: - en_US: Database Name - zh_Hans: 数据库名 - pt_BR: Nome do Banco de Dados - human_description: - en_US: "The name of the OceanBase database." - zh_Hans: "OceanBase数据库的名称。" - pt_BR: "O nome do banco de dados OceanBase." - llm_description: "The name of the OceanBase database." - form: llm - - name: query - type: string - required: true - label: - en_US: SQL Query - zh_Hans: SQL查询语句 - pt_BR: Consulta SQL - human_description: - en_US: "The SQL query to execute against the OceanBase database." - zh_Hans: "要在OceanBase数据库上执行的SQL查询语句。" - pt_BR: "A consulta SQL a ser executada no banco de dados OceanBase." - llm_description: "The SQL query to execute against the OceanBase database." - form: llm -extra: - python: - source: tools/oceanbase_db_plugin.py