Skip to content

Commit

Permalink
fixed hhyo#2252
Browse files Browse the repository at this point in the history
使用connection.current_schema=db_name代替 cursor.execute(f' ALTER SESSION SET CURRENT_SCHEMA = "{db_name}" ')
参考 https://cx-oracle.readthedocs.io/en/latest/api_manual/connection.html?highlight=CURRENT_SCHEMA#Connection.current_schema
但是仅自测 cx-oracle 7.3.0 版本
  • Loading branch information
tonyhu214 authored Aug 24, 2023
1 parent 5e5c0f8 commit f8dfc09
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions sql/engines/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,10 +590,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},
)
conn.current_schema=db_name
if re.match(r"^explain", sql, re.I):
sql = sql
else:
Expand Down Expand Up @@ -669,10 +666,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},
)
conn.current_schema=db_name
sql = sql.rstrip(";")
# 支持oralce查询SQL执行计划语句
if re.match(r"^explain", sql, re.I):
Expand Down

0 comments on commit f8dfc09

Please sign in to comment.