Ejemplo n.º 1
0
    def unmannedshifts(self):
        mydb = mysql.connector.connect(host="localhost",
                                       user="******",
                                       password='******',
                                       database='flight_manager',
                                       auth_plugin='mysql_native_password')
        mycursor = mydb.cursor()
        query = """
            SELECT flight_manager.shifts.flight_date,  flight_manager.shifts.flight_type,  flight_manager.type_of_shift.crew_role,  flight_manager.type_of_shift.leader
            from flight_manager.shifts join flight_manager.type_of_shift
            on shifts.flight_type = type_of_shift.flight_type 
            left join flight_manager.staffing
            on flight_manager.shifts.flight_date = flight_manager.staffing.flight_date
            and flight_manager.type_of_shift.flight_type = flight_manager.staffing.flight_type
            and (flight_manager.type_of_shift.crew_role = flight_manager.staffing.crew_role
            or flight_manager.type_of_shift.crew_role = 'all')
            and flight_manager.type_of_shift.leader = flight_manager.staffing.leader
            where personal_num is NULL

            
                """
        mycursor.execute(query)
        results = mycursor.fetchall()
        mydb.commit()
        unmenned_shifts = []
        count = 1
        for row in results:
            shift = Shift()
            shift.number = count
            count = count + 1
            shift.flight_date = str(row[0])
            shift.flight_type = str(row[1]).capitalize()
            shift.crew_role = str(row[2]).capitalize()
            if str(row[3]) == '1':
                shift.leader = 'Must Be Movil'
            elif str(row[3]) == '0':
                shift.leader = 'Number 2'
            else:
                shift.leader = 'All'
            unmenned_shifts.append(shift)
        return unmenned_shifts
Ejemplo n.º 2
0
    def unmannedshifts(self):
        mydb = mysql.connector.connect(host="us-cdbr-iron-east-01.cleardb.net", user="******",
                                       password='******', database='heroku_947e29c06a5b4a3')

        mycursor = mydb.cursor()
        query = """
            SELECT shifts.flight_date,  shifts.flight_type,  type_of_shift.crew_role,  type_of_shift.leader
            from shifts join type_of_shift
            on shifts.flight_type = type_of_shift.flight_type 
            left join staffing
            on shifts.flight_date = staffing.flight_date
            and type_of_shift.flight_type = staffing.flight_type
            and (type_of_shift.crew_role = staffing.crew_role
            or type_of_shift.crew_role = 'all')
            and type_of_shift.leader = staffing.leader
            where personal_num is NULL

            
                """
        mycursor.execute(query)
        results = mycursor.fetchall()
        mydb.commit()
        mycursor.close()
        unmenned_shifts = []
        count = 1
        for row in results:
            shift = Shift()
            shift.number = count
            count = count +1
            shift.flight_date = str(row[0])
            shift.flight_type = str(row[1]).capitalize()
            shift.crew_role =str(row[2]).capitalize()
            if str(row[3]) =='1':
                shift.leader = 'Must Be Movil'
            elif str(row[3]) == '0':
                shift.leader = 'Number 2'
            else :
                shift.leader = 'All'
            unmenned_shifts.append(shift)
        return unmenned_shifts