Skip to content

[Feature Request - RAGFlow+OceanBase] Add OceanBase Support to Text-to-SQL Agent #12768

@yuzhichang

Description

@yuzhichang

Overview

RAGFlow's Text-to-SQL functionality (via the ExeSQL agent component) currently supports MySQL, PostgreSQL, MariaDB, MSSQL, IBM DB2, and Trino databases. This feature request aims to add OceanBase database support to the ExeSQL component, enabling users to execute SQL queries against OceanBase through natural language.

Technical Details

Location

  • agent/tools/exesql.py - Main ExeSQL component implementation

Current Implementation

The ExeSQL component supports multiple database types:

  • Line 56: Database type validation in check() method
    self.check_valid_value(self.db_type, "Choose DB type", 
        ['mysql', 'postgres', 'mariadb', 'mssql', 'IBM DB2', 'trino'])
  • Lines 126-179: Database connection logic using different Python drivers:
    • mysql, mariadbpymysql
    • postgrespsycopg2
    • mssqlpyodbc
    • trinotrino
    • IBM DB2ibm_db

Implementation Plan

  1. Add OceanBase to valid database types (Line 56)

    self.check_valid_value(self.db_type, "Choose DB type", 
        ['mysql', 'postgres', 'mariadb', 'mssql', 'IBM DB2', 'trino', 'oceanbase'])
  2. Add OceanBase connection logic (After line 131)

    elif self._param.db_type == 'oceanbase':
        # OceanBase MySQL compatibility mode
        db = pymysql.connect(db=self._param.database, user=self._param.username, 
                            host=self._param.host, port=self._param.port, 
                            password=self._param.password)
  3. Consider adding charset parameter (optional, for better compatibility)

    db = pymysql.connect(db=self._param.database, user=self._param.username, 
                        host=self._param.host, port=self._param.port, 
                        password=self._param.password, charset='utf8mb4')
  4. Front end ui adaptation (MUST)

Image

Core Functionality

The ExeSQL component provides:

  • SQL Execution: Execute SQL queries generated by LLM from natural language
  • Multi-statement Support: Handle multiple SQL statements separated by semicolons
  • Result Formatting: Return results in both JSON and Markdown table formats
  • Connection Management: Proper cursor and connection cleanup
  • Decimal Handling: Convert Decimal types to float for JSON serialization
  • DateTime Formatting: Format datetime columns to YYYY-MM-DD
  • Max Records Limit: Respect max_records parameter (default: 1024)

Dependencies

  • pymysql - Already in use for MySQL/MariaDB
  • No additional dependencies required for OceanBase (uses MySQL compatibility mode)

Estimated Effort

  • Code size: ~10 lines
  • Difficulty: ⭐ Simple
  • Priority: 🔴 High

Related Files

  • agent/tools/exesql.py - Main implementation file
  • agent/templates/sql_assistant.json - SQL Assistant workflow template
  • agent/test/dsl_examples/exesql.json - Example DSL configuration

Acceptance Criteria

Provide screenshot(s) demonstrating:

  1. ExeSQL component configuration with db_type: "oceanbase"
  2. Successfully connecting to an OceanBase database
  3. Executing a SQL query (e.g., SELECT * FROM table LIMIT 10)
  4. Query results returned correctly in the RAGFlow Agent UI

Example test scenario:

Input: "Show me all users from the users table"
LLM generates: "SELECT * FROM users LIMIT 10;"
ExeSQL executes against OceanBase → Results displayed

Background

This is part of the RAGFlow + OceanBase Hackathon. Adding OceanBase support to the Text-to-SQL agent will enable users to query OceanBase databases using natural language through RAGFlow's AI-powered SQL Assistant, leveraging OceanBase's MySQL compatibility mode for seamless integration.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions