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 name below):
In SitePage.py: dbPool = MiscUtils.DBPool.DBPool(DCOracle2, 10, 'user/passwd@instance') 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 from SitePage. In, say, Main.py, here's how to print the time as selected from the database: db = self.dbPool.getConnection() c = db.cursor() c.execute("select to_char(sysdate, 'HH:MI:SS') from dual") res = c.fetchall() self.write(res[0][0]) # the only row returned, one column, containing the time c.close() db.close() 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. Cheers! -- David Hancock | [EMAIL PROTECTED] | 410-266-4384 -----Original Message----- From: Costas Malamas [mailto:[EMAIL PROTECTED]] Sent: Friday, May 03, 2002 9:56 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] 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? subclass Application? C. >From: Chuck Esterbrook <[EMAIL PROTECTED]> >To: [EMAIL PROTECTED] >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. > >-Chuck > > >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: >[EMAIL PROTECTED] >_______________________________________________ >Webware-discuss mailing list >[EMAIL PROTECTED] >https://lists.sourceforge.net/lists/listinfo/webware-discuss _________________________________________________________________ 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: [EMAIL PROTECTED] _______________________________________________ Webware-discuss mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/webware-discuss _______________________________________________________________ Have big pipes? SourceForge.net is looking for download mirrors. We supply the hardware. You get the recognition. Email Us: [EMAIL PROTECTED] _______________________________________________ Webware-discuss mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/webware-discuss