def __init__(self):
''' creates a connection at the initialization moment
and also a cursor used later '''
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()
except MySQLdb.Error, e:
print "Error %d: %s" % (e.args[0], e.args[1])
sys.exit (1)
def __init__(self):
while True:
''' creates a connection at the initialization moment
and also a cursor used later '''
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()
break
except MySQLdb.Error, e:
print "Error %d: %s" % (e.args[0], e.args[1])
time.sleep(5)