Re: can i set up a mysql db connection as a class ?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: can i set up a mysql db connection as a class ?

From: Ed Leafe <ed@leafe.com>
Date: Sat Apr 29 2006 - 16:26:55 CEST

On Apr 27, 2006, at 8:15 PM, nephish@xit.net wrote:

> my question is, is there a way i can set up a global connection so
> that
> when the program loads, it connects once, then stays connected ? maybe
> i could assign instances of the cursor ?

        We do something like this in Dabo. We define connections, giving
each an identifying name, and the application object loads the
definitions at startup (without actually connecting). When a business
object needs a connection, they call
self.Application.getConnectionByName(connName). If that connection
hasn't been made, the app connects and returns a reference to the
connection. It also stores the reference, so that the next time a
business object requests that connection, it simply returns the
existing reference.

<shameless plug>
        If you're developing database applications, especially if they
involve a GUI, you really should take a look at Dabo. It's an app
framework written by database developers for database developers.
</shameless plug>

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com
Received on Mon May 1 00:43:47 2006