怎么样:
conn = MySQLdb.connect(host, user, password, database)cursor = conn.cursor()attempts = 0while attempts < 3: try: cursor.execute(query) rows = cursor.fetchall() for row in rows: # do something with the data break except MySQLdb.Error, e: attempts += 1 print "MySQL Error %d: %s" % (e.args[0], e.args[1])
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)