Quick disclaimer: I'm no expert, I'm new to Python, I'm new to Webware.
Here's how I use DBPool (I'm using DCOracle2, so substitute your DB module
dbPool = MiscUtils.DBPool.DBPool(DCOracle2, 10, 'user/passwd@...')
This makes a pool of 10 Oracle connections, which you can verify by doing:
ps aux | grep oracle<instance>
On your database machine after you've executed any servlet that inherits
In, say, Main.py, here's how to print the time as selected from the
db = self.dbPool.getConnection()
c = db.cursor()
c.execute("select to_char(sysdate, 'HH:MI:SS') from dual")
res = c.fetchall()
self.write(res) # the only row returned, one column, containing
There's no trick from the caller's perspective. When you ask for a
connection, rather than opening a fresh Oracle connection, DBPool simply
returns the next one "in line."
I hope this helps.
David Hancock | dhancock@... | 410-266-4384
From: Costas Malamas [mailto:costasm@...]
Sent: Friday, May 03, 2002 9:56 AM
To: ChuckEsterbrook@...; webware-discuss@...
Subject: Re: [Webware-discuss] DB Connection Pulling
Well, I am convinced, I'll go ahead and try it out.
What I am not following from the docs though is how do you use DBPool; I am
not familiar with threading (at all!), so I don't get the setup. E.g. do
you call DBPool once in your application (somehow have a central DBPool that
you get connections from) or do can you call it whenever you need a
connection and it will "know" which connection to give back? I am guessing
the former --in which case, where in WK is the best place to put it?
>From: Chuck Esterbrook <ChuckEsterbrook@...>
>Subject: Re: [Webware-discuss] DB Connection Pulling
>Date: Thu, 2 May 2002 16:29:37 -0700
>I did, in fact, experience a speedup when using DBPool with MySQL, so I
>removed that comment from the source code.
>I use DBPool on my production site (via a MiddleKit setting) with MySQL
>at 20 connections.
>On Thursday 02 May 2002 03:11 pm, Hancock, David \(DHANCOCK\) wrote:
> > I only recollect that it was reported that there was no speed boost
> > using MySQL, and nobody else had reported any results.
> > My testing has shown about 10:1 performance boost using DBPool.py to
> > pool connections to Oracle. After looking at the database machine
> > I'm connecting to, I can tell you for certain that the connections
> > are being pooled and allocated in a nice round-robin fashion.
> > It's to be expected that MySQL doesn't show a performance boost,
> > because the "cost of connection" is very low. Oracle's cost of
> > connection is high, and that's why it speeds up so nicely when the
> > connections are pooled.
> > Cheers!
>Have big pipes? SourceForge.net is looking for download mirrors. We
>supply the hardware. You get the recognition. Email Us:
>Webware-discuss mailing list
Send and receive Hotmail on your mobile device: http://mobile.msn.com
Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: bandwidth@...
Webware-discuss mailing list Webware-discuss@...