can i set up a mysql db connection as a class ?
nephish at xit.net
nephish at xit.net
Fri Apr 28 00:49:24 EDT 2006
This is great !
ok, i dont really have a lot of time to get into the ORMS (before your
post, this is the first i have heard of it) and my stuff is due on
Monday. he he.
but, if i am able to make a global db connection, and multiple cursors
pointing to the same connection object, how do i pull that off without
making new db connections?
something like
class db(self):
def __init__(self):
db = MySQLdb.connect(host="localhost", user="MyUser",
passwd="MyPassword",
db="Stuff")
def cursor(self):
cursor = db.cursor()
return cursor
then have in my threads that need to connect
cursor = db.cursor()
cursor2 = db.cursor()
and so on ? i may be way outta whack here. i am still new at classes,
methods, and modules.
i do have Essential Reference on the way from Amazon though ! :)
thanks again
More information about the Python-list
mailing list