can i set up a mysql db connection as a class ?
Ed Leafe
ed at leafe.com
Sat Apr 29 10:26:55 EDT 2006
On Apr 27, 2006, at 8:15 PM, nephish at 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
More information about the Python-list
mailing list