I am having some trouble controlling my database connection. I have one module DbConnection.py that handles connecting to the database. I call it and get returned the database handle object just fine. as such
I have another module to handle certain queries (this is a multi step process each being call as cgi scripts).
The trouble I am having is in Order.
How do I instantiate it class wide? I could just create a connection wherever I call the create function but don't want to have too many open connections at any given time. Any help?
Code:
dbh = DbConnection.new()
I have another module to handle certain queries (this is a multi step process each being call as cgi scripts).
Code:
Order.SetDatabaseHandle(dbh)
The trouble I am having is in Order.
Code:
#
# Class variables
#
dbh # Database Handle [COLOR=red]I need to instantiate the handle class wide[/color]
def SetDatabaseHandle(data):
dbh = data
def Create(data):
cursor = dbh.cursor()
How do I instantiate it class wide? I could just create a connection wherever I call the create function but don't want to have too many open connections at any given time. Any help?