Re: Python List to store connections.
What does
not working mean? What error do you get? Any traceback?
>>> import MySQLdb
>>> db = list()
>>> for i in [0, 1, 2, 3, 4]:
... try:
... db.append(MySQLdb.connect(db="test", host="localhost", user="u", passwd="p"))
... print "Connected %s" % (i,)
... except:
... print "Can't connect to the server"
... break
...
Connected 0
Connected 1
Connected 2
Connected 3
Connected 4
>>> print "\n".join(["%r" % (dbi,) for dbi in db])
<_mysql.connection open to 'localhost' at 8151854>
<_mysql.connection open to 'localhost' at 81c5f1c>
<_mysql.connection open to 'localhost' at 81c886c>
<_mysql.connection open to 'localhost' at 81c91e4>
<_mysql.connection open to 'localhost' at 81c9b5c>
Subject
Written By
Posted
Re: Python List to store connections.
March 07, 2008 09:12AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.