在oracle DB上从python运行set role命令

在oracle DB上从python运行set role命令,python,oracle,cx-oracle,Python,Oracle,Cx Oracle,我试图在python中的OracleDB上创建一个角色 设置XYZ标识的角色名称 我尝试的代码是: self._connection = cx_Oracle.connect(self._configHelper.get_oracledb_connection_string()) cursor = self._connection.cursor() cursor.execute('Set role role_name identified by xyz') results = list(curso

我试图在python中的OracleDB上创建一个角色

设置XYZ标识的角色名称

我尝试的代码是:

self._connection = cx_Oracle.connect(self._configHelper.get_oracledb_connection_string())
cursor = self._connection.cursor()
cursor.execute('Set role role_name identified by xyz')
results = list(cursor.fetchall())
当我尝试这个时,我得到了“接口错误:不是查询”。但是当我使用SQLDeveloper运行它时,它确实工作得很好,所以查询中没有错误

我也试过了

cursor.callproc('Set role role_name identified by xyz')
第1行第11列显示无效字符


有人能告诉我在Python中执行此命令的正确方法吗?

尝试使用execute immediate执行PL/SQL块:

begin
  execute immediate 'Set role role_name identified by xyz';
end;

我的代码错了,我用了

results=cursor.fetchall()

我想我会检查一下状态,正是这句话造成了问题。所以解决办法是

self.\u connection=cx\u Oracle.connect(self.\u configHelper.get\u oracledb\u connection\u string())
cursor=self.\u connection.cursor()

cursor.execute('Set role role\u name由xyz标识')

很抱歉,这是我的错误,我有results=list(cursor.fetchall()),它抱怨这不是一个查询,我以为是cursor.execute