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, mariadb → pymysql
postgres → psycopg2
mssql → pyodbc
trino → trino
IBM DB2 → ibm_db
Implementation Plan
-
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'])
-
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)
-
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')
-
Front end ui adaptation (MUST)
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:
- ExeSQL component configuration with
db_type: "oceanbase"
- Successfully connecting to an OceanBase database
- Executing a SQL query (e.g.,
SELECT * FROM table LIMIT 10)
- 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.
Overview
RAGFlow's Text-to-SQL functionality (via the
ExeSQLagent 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 implementationCurrent Implementation
The ExeSQL component supports multiple database types:
check()methodmysql,mariadb→pymysqlpostgres→psycopg2mssql→pyodbctrino→trinoIBM DB2→ibm_dbImplementation Plan
Add OceanBase to valid database types (Line 56)
Add OceanBase connection logic (After line 131)
Consider adding charset parameter (optional, for better compatibility)
Front end ui adaptation (MUST)
Core Functionality
The ExeSQL component provides:
YYYY-MM-DDmax_recordsparameter (default: 1024)Dependencies
pymysql- Already in use for MySQL/MariaDBEstimated Effort
Related Files
agent/tools/exesql.py- Main implementation fileagent/templates/sql_assistant.json- SQL Assistant workflow templateagent/test/dsl_examples/exesql.json- Example DSL configurationAcceptance Criteria
Provide screenshot(s) demonstrating:
db_type: "oceanbase"SELECT * FROM table LIMIT 10)Example test scenario:
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.