Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

feature:Add OceanBase Support to Text-to-SQL Agent (#12919)

Carve_ee23b9eb630b
diff --git a/agent/tools/exesql.py b/agent/tools/exesql.py
index 8f3f9dd175..3f969f4316 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 14dc52a449..6f73c68cb9 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 9d68ec70bf..c74bf0b488 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,