简体   繁体   English

cx_Oracle 中的应用程序名称

[英]Application name in cx_Oracle

I am connecting to an Oracle Database Server using a SessionPool from cx_Oracle.我正在使用来自 cx_Oracle 的 SessionPool 连接到 Oracle 数据库服务器。 When I look at the description of the opened session in the Oracle developer, I see that its name is "python.exe".当我查看Oracle开发人员中打开的session的描述时,我看到它的名字是“python.exe”。 How can I set the application/module name in cx_oracle?如何在 cx_oracle 中设置应用程序/模块名称?

You may be able to physically rename python.exe but there is no programmatic way to change what is shown in Oracle Database as the executable.您可能能够以物理方式重命名 python.exe,但没有编程方式可以将 Oracle 数据库中显示的内容更改为可执行文件。

You can set the driver name by calling cx_Oracle.init_oracle_client .您可以通过调用cx_Oracle.init_oracle_client来设置驱动程序名称。 This changes the CLIENT_DRIVER column of V$SESSION_CONNECT_INFO.这将更改 V$SESSION_CONNECT_INFO 的 CLIENT_DRIVER 列。

Other settable attributes including 'module' (which in Oracle terminology is not the program name) are shown in the documentation Oracle Database End-to-End Tracing .其他可设置属性包括“模块”(在 Oracle 术语中不是程序名称)显示在文档Oracle Database End-to-End Tracing中。

# Set the tracing metadata
connection.client_identifier = "pythonuser"
connection.action = "Query Session tracing parameters"
connection.module = "End-to-end Demo"

for row in cursor.execute("""
        SELECT username, client_identifier, module, action
        FROM V$SESSION
        WHERE username = 'SYSTEM'"""):
    print(row)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM