import MySQLdbmyDB = MySQLdb.connect(host="127.0.0.1", port=3306, db="schedule")cHandler = myDB.cursor()sqlCommand = "SELECT * FROM Arrivals WHERE city = 'Dallas'"cHandler.execute(sqlCommand)results = cHandler.fetchall()print resultssqlCommand = "SELECT * FROM Arrivals"cHandler.execute(sqlCommand)results = cHandler.fetchall()print resultscityList = []flightList = []timeList = []for row in results: cityList.append(row[0]) flightList.append(row[1]) timeList.append(row[2])x = 0for flight in flightList: print ("Flight %s arrives from %s at %s" % (flight, cityList[x], timeList[x])) x+=1myDB.close()
Name (required)
email (will not be published) (required)
Website