[cx-oracle-users] Overwriting connection.action and connection.module?
Brought to you by:
atuining
|
From: Zoltan F. <zol...@gm...> - 2015-07-16 13:59:57
|
Hi,
I'm having a hard time using connection.action
I'm a long-time PHP OCI user and just switching over to cx_Oracle. I always
thought that the "action" attribute of the Oracle session is there to show
what action the current query is making, so I always used it to basically
provide a short verbal explanation of what the query is doing. This is
specially useful for ETL-style, long running queries, so the DBA can see
what that query is doing which is running for over 30 mins now, so he won't
just kill it.
In line with this, in PHP OCI I can have an oracle connection open and
overwrite the "action" attribute everytime a submit a new query (hence it
can be used to describe what the query is doing).
Unfortunately it seems to me that in cx_Oracle the "connection.action" (and
"connection.module") can only be submitted once and not overwritten later.
I'm using cx_Oracle 5.2 in Python 3.4.3 with Oracle 11.2.1
See below example code to reproduce. What you will see that while the query
is running the action (and module) in the Oracle $SESSION table is showing
the first value ("dual query") and NOT the second one ("2-dual query").
As such, I can only set the action once within a single Oracle connection,
which makes it useless for the purposes of explaining what the query is
doing, because you cannot set it for each query you are running within the
same connection (if you run only one query per connection, then obviously
this is a non-issue).
*import cx_Oracle, time*
*con = cx_Oracle.connect("user/password@//oracle_server:1521/test")*
*con.module="query module"*
*con.action="dual query"*
*time.sleep(3) # delay a little*
*# now let's supply a new module and action*
*con.module="2-query module" *
*con.action="2-dual query" *
*cur = con.cursor()*
*cur.execute("""*
*RUN A QUERY HERE WHICH RUNS FOR LONG ENOUGH FOR YOU TO CHECK THE SESSION
DATA IN ORACLE""")*
*con.close()*
Would this be a bug or am I doing something wrong here?
Thanks,
Zoltan
|