« oracle-validated RPMs now available outside of ULN | Main | Where to Download Oracle VM Templates »

cx_Oracle and DBMS_APPLICATION_INFO

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

TrackBack

TrackBack URL for this entry:
http://blogs.oracle.com/mte1521/mt-tb.cgi/6066

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About This Entry

This page contains a single entry from the blog posted on August 29, 2008 10:51 AM.

The previous post in this blog was oracle-validated RPMs now available outside of ULN.

The next post in this blog is Where to Download Oracle VM Templates.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type and Oracle