2 Replies Latest reply: Jun 12, 2008 2:19 PM by 615703 RSS

    mod_python + cx_Oracle.SessionPool

    615703
      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.

      mod_python-3.3.1
      cx_Oracle-4.2.1
      Oracle 10g Release 2

      Jason
        • 1. Re: mod_python + cx_Oracle.SessionPool
          cj
          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
          cursor.execute("""
                  select city
                  from locations""")
          for city in cursor.fetchall():
              print "Values:", city

          pool.release(db)
          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)
          • 2. Re: mod_python + cx_Oracle.SessionPool
            615703
            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.

            Jason