Forum Stats

  • 3,817,470 Users
  • 2,259,339 Discussions


mod_python + cx_Oracle.SessionPool

615703 Member Posts: 9
edited Jun 12, 2008 3:19PM in Python
Greetings all,

I am working with mod_python, using Python Server Pages, and I am researching the use of connection pooling from cx_Oracle for this web app.
Does anyone have experience with this that could shed some light on where I should start?
I am relatively new to Python and I haven't found any revelations from my perusing of the mod_python documentation
(although it might be there and I am just not getting it). I appreciate any advice you can provide.

Oracle 10g Release 2



  • Christopher Jones-Oracle
    Christopher Jones-Oracle Member Posts: 1,644 Employee
    Cx_Oracle has session pooling:
    import cx_Oracle

    pool = cx_Oracle.SessionPool(user='hr',password='hrpwd',dsn='localhost/orcl',min=1,max=2,increment=1)
    db = pool.acquire()

    cursor = db.cursor()
    cursor.arraysize = 50
    select city
    from locations""")
    for city in cursor.fetchall():
    print "Values:", city

    If you link Python with Oracle 11g libraries and connect to an Oracle 11g database you can also use "Database Resident Connection Pooling (DRCP)" by adding "pooled" to the connection string:
    pool = cx_Oracle.SessionPool(user='hr',password='hrpwd',dsn='localhost/orcl:pooled',min=1,max=2,increment=1)
  • 615703
    615703 Member Posts: 9
    Thanks for the reply.

    I am aware of the SessionPool functionality provided via cx_Oracle but what I was looking for was some guidance on how to implement with mod_python and Apache.
    Specifically, can I keep the connection pool around between requests that are sent to the web server?
    Appreciate any input.

This discussion has been closed.