diff --git a/sql/engines/oracle.py b/sql/engines/oracle.py index 31cabbbbd3..1b05dfa325 100644 --- a/sql/engines/oracle.py +++ b/sql/engines/oracle.py @@ -593,10 +593,7 @@ def explain_check(self, db_name=None, sql="", close_conn=False): conn = self.get_connection() cursor = conn.cursor() if db_name: - cursor.execute( - f" ALTER SESSION SET CURRENT_SCHEMA = :db_name ", - {"db_name": db_name}, - ) + cursor.execute(f' ALTER SESSION SET CURRENT_SCHEMA = "{db_name}" ') if re.match(r"^explain", sql, re.I): sql = sql else: @@ -609,7 +606,7 @@ def explain_check(self, db_name=None, sql="", close_conn=False): ) rows = cursor.fetchone() conn.rollback() - if not rows: + if rows[0] is None or not rows: result["rows"] = 0 else: result["rows"] = rows[0] @@ -672,10 +669,7 @@ def query( conn = self.get_connection() cursor = conn.cursor() if db_name: - cursor.execute( - f" ALTER SESSION SET CURRENT_SCHEMA = :db_name ", - {"db_name": db_name}, - ) + cursor.execute(f' ALTER SESSION SET CURRENT_SCHEMA = "{db_name}" ') sql = sql.rstrip(";") # 支持oralce查询SQL执行计划语句 if re.match(r"^explain", sql, re.I):