Answer the question
In order to leave comments, you need to log in
How to reconnect to the database after die?
Good evening. There is here such connection to a DB. If you manually kill (kill), then how then to reconnect to it?
def __init__(self):
''' creates a connection at the initialization moment
and also a cursor used later '''
connct = False
while connct != True:
try:
# creates a connection
self.conn = MySQLdb.connect( host = self.dbhost,
port = self.dbport,
user = self.dbuser,
passwd = self.dbpass
)
self.cursor = self.conn.cursor()
connct = True
except MySQLdb.Error, e:
print "Error %d: %s" % (e.args[0], e.args[1])
time.sleep(5)
connct = False
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question