mysqldb

K

ketulp_baroda

Hi
I am using MySQLdb. I want to know how can I check whether a
connection is open or not.If it is open I want to use the existing
connection else create a new connection by
db=MySQLdb.connection(.........)
 
W

wes weston

ketulp,
Can you default the connection to None.

def foo(x,y,z,connection=None):
if not connection:
connection = OpenMyConnection()
.....

You could then use foo with or without an open
connection.

wes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,176
Messages
2,570,950
Members
47,503
Latest member
supremedee

Latest Threads

Top