def goaltracker(self): mydb = mysql.connector.connect(host="localhost", user="******", password='******', database='flight_manager', auth_plugin='mysql_native_password') mycursor = mydb.cursor() query = """ select flight_manager.air_crew.personal_number, flight_manager.auth_user.first_name, flight_manager.auth_user.last_name, flight_manager.air_crew.goal, count(flight_manager.staffing.personal_num) As achieved from flight_manager.auth_user join flight_manager.air_crew on flight_manager.auth_user.username = flight_manager.air_crew.personal_number left join flight_manager.staffing on flight_manager.air_crew.personal_number = flight_manager.staffing.personal_num group by air_crew.personal_number; """ mycursor.execute(query) results = mycursor.fetchall() mydb.commit() air_goals = [] for row in results: air_crew = AirCrew() air_crew.personal_num = str(row[0]) air_crew.first_name = str(row[1]).capitalize() air_crew.last_name = str(row[2]).capitalize() air_crew.goal = str(row[3]) air_crew.achieved = str(row[4]) air_goals.append(air_crew) return air_goals
def goaltracker(self): mydb = mysql.connector.connect(host="us-cdbr-iron-east-01.cleardb.net", user="******", password='******', database='heroku_947e29c06a5b4a3') mycursor = mydb.cursor() query = """ select air_crew.personal_number, auth_user.first_name, auth_user.last_name, air_crew.goal, count(staffing.personal_num) As achieved from auth_user join air_crew on auth_user.username = air_crew.personal_number left join staffing on air_crew.personal_number = staffing.personal_num group by air_crew.personal_number; """ mycursor.execute(query) results = mycursor.fetchall() mydb.commit() mycursor.close() air_goals = [] for row in results: air_crew = AirCrew() air_crew.personal_num = str(row[0]) air_crew.first_name = str(row[1]).capitalize() air_crew.last_name = str(row[2]).capitalize() air_crew.goal = str(row[3]) air_crew.achieved = str(row[4]) air_goals.append(air_crew) return air_goals