From ee23b9eb630bf5d49aa2f91cb3d2341d25f19c70 Mon Sep 17 00:00:00 2001
From: Carve_ <75568342+Rynzie02@users.noreply.github.com>
Date: Sat, 31 Jan 2026 15:03:40 +0800
Subject: [PATCH] feature:Add OceanBase Support to Text-to-SQL Agent (#12919)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
### What problem does this PR solve?
Close #12768.
This PR adds OceanBase support to RAGFlow’s Text-to-SQL (ExeSQL)
component.
OceanBase is integrated via MySQL compatibility mode, and the UI
`db_type` options are updated accordingly.
### Type of change
- [ ] Bug Fix (non-breaking change which fixes an issue)
- [x] New Feature (non-breaking change which adds functionality)
- [ ] Documentation Update
- [ ] Refactoring
- [ ] Performance Improvement
- [ ] Other (please describe):
### Changes
**Backend**
- Add `oceanbase` `db_type` validation and connection logic in
`exesql.py` and reuse existing MySQL compatibility mode
**Frontend**
- Add OceanBase option to the ExeSQL `db_type` selector
### How to test
1. Configure OceanBase connection in ExeSQL node
(host/port/user/password/database)
2. Input: “Show 10 rows from test table”
3. Generated SQL: `SELECT * FROM test LIMIT 10;`
4. Query executes successfully and results are returned
### Screenshots
- ExeSQL db_type includes OceanBase
- ExeSQL test OceanBase connection
- Query results from OceanBase shown in UI
---
agent/tools/exesql.py | 5 ++++-
api/apps/canvas_app.py | 3 +++
web/src/pages/agent/options.ts | 1 +
3 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/agent/tools/exesql.py b/agent/tools/exesql.py
index 8f3f9dd17..3f969f431 100644
--- a/agent/tools/exesql.py
+++ b/agent/tools/exesql.py
@@ -53,7 +53,7 @@ class ExeSQLParam(ToolParamBase):
self.max_records = 1024
def check(self):
- self.check_valid_value(self.db_type, "Choose DB type", ['mysql', 'postgres', 'mariadb', 'mssql', 'IBM DB2', 'trino'])
+ self.check_valid_value(self.db_type, "Choose DB type", ['mysql', 'postgres', 'mariadb', 'mssql', 'IBM DB2', 'trino', 'oceanbase'])
self.check_empty(self.database, "Database name")
self.check_empty(self.username, "database username")
self.check_empty(self.host, "IP Address")
@@ -126,6 +126,9 @@ class ExeSQL(ToolBase, ABC):
if self._param.db_type in ["mysql", "mariadb"]:
db = pymysql.connect(db=self._param.database, user=self._param.username, host=self._param.host,
port=self._param.port, password=self._param.password)
+ elif self._param.db_type == 'oceanbase':
+ 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')
elif self._param.db_type == 'postgres':
db = psycopg2.connect(dbname=self._param.database, user=self._param.username, host=self._param.host,
port=self._param.port, password=self._param.password)
diff --git a/api/apps/canvas_app.py b/api/apps/canvas_app.py
index 14dc52a44..6f73c68cb 100644
--- a/api/apps/canvas_app.py
+++ b/api/apps/canvas_app.py
@@ -326,6 +326,9 @@ async def test_db_connect():
if req["db_type"] in ["mysql", "mariadb"]:
db = MySQLDatabase(req["database"], user=req["username"], host=req["host"], port=req["port"],
password=req["password"])
+ elif req["db_type"] == "oceanbase":
+ db = MySQLDatabase(req["database"], user=req["username"], host=req["host"], port=req["port"],
+ password=req["password"], charset="utf8mb4")
elif req["db_type"] == 'postgres':
db = PostgresqlDatabase(req["database"], user=req["username"], host=req["host"], port=req["port"],
password=req["password"])
diff --git a/web/src/pages/agent/options.ts b/web/src/pages/agent/options.ts
index 9d68ec70b..c74bf0b48 100644
--- a/web/src/pages/agent/options.ts
+++ b/web/src/pages/agent/options.ts
@@ -2140,6 +2140,7 @@ export const ExeSQLOptions = [
'mssql',
'IBM DB2',
'trino',
+ 'oceanbase',
].map((x) => ({
label: upperFirst(x),
value: x,