Forum Stats

  • 3,854,197 Users
  • 2,264,340 Discussions


How to use Connection.clientinfo with v$session table

700084 Member Posts: 4
edited Oct 18, 2009 8:02PM in Python
Hi everyone,

I'm trying to keep tabs on the number of connections I create (via python and cx_Oracle) by monitoring Oracle's v$session table.

From the cx_Oracle docs, it appears the preferred way to write my "module" and "action" parameters to v$session is via the Connection.clientinfo method.

I tried creating a connection and using that method, but the results did not appear in the v$session table. Below is how I called the method:

cnx.clientinfo(module="name of module", action="myaction")

Is that the correct way to use "clientinfo"?

The cx_Oracle docs don't provide any usage examples (that I could find), and only point to the Python DB API specs. I didn't notice a mention of this method there:

Can anyway show me an example of how to use the "clientinfo" method? Also, is it necessary to have "write" permission for my username in order to access v$session? If so, perhaps that's my problem...


  • 604934
    604934 Member Posts: 86
    edited Oct 18, 2009 8:02PM
    C:\Documents and Settings\tchsensoy>python
    Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on win32
    import cx_Oracle
    con = cx_Oracle.connect("player/[email protected]")
    cur = con.cursor()
    con.module="query module"
    con.action="dual query"
    con.clientinfo="Husnu Sensoy"
    # Run below SQL after running this line ....
    cur.execute("select dummy from dual")
    select s.PROGRAM, s.CLIENT_INFO, module, action from v$session s where username = 'PLAYER' and program = 'python.exe';

    ----------------- ---------------------- ----------------------- --------------------------------
    python.exe Husnu Sensoy query module dual query

    Hüsnü Şensoy

    Edited by: HSensoy on 19.Eki.2009 02:58

    Edited by: HSensoy on 19.Eki.2009 02:59

    Edited by: HSensoy on 19.Eki.2009 03:00
This discussion has been closed.