Here's another post from the old blog, harvested from archive.org
The other day I was playing with some Python and cx_Oracle, a Python module for connecting to Oracle databases. While cx_Oracle seems to work great, I found the documentation light on examples. Because I follow Tom Kyte's advice closely, I was trying to instrument my code with some calls to DBMS_APPLICATION_INFO. As it turns out, the cx_Oracle connection object has write only attributes to set module, action, and clientinfo.
Here's a quick example of that in action (warning: newbie Python ahead)
-bash-3.00$ python
Python 2.3.4 (#1, Feb 2 2005, 11:44:49)
[GCC 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
>>> con=cx_Oracle.connect ("hr/hr")
>>> cur=con.cursor()
>>> con.module="python module"
>>> con.action="some big query"
>>> cur.execute ("select 1 from dual")
[<cx_Oracle.NUMBER with value None>]
>>> con.action=""
>>> con.module=""
>>> con.close()
Before closing the connection with con.close(), this is what was observed in the database:
SQL> select sid, module, action from v$session where module is not null
2 /
SID MODULE ACTION
---------- ------------------------------------------------ --------------------------------
22 sqlplus@captain.us.oracle.com (TNS V1-V3)
26 python module some big query