Flight Record

Represents a single record in the Startkladde flights table, which contains one record for each flight stored in the database.

Interface

class pysk.db.model.Flight(id=None, plane_id=None, pilot_id=None, copilot_id=None, type=None, mode=None, departed=None, landed=None, towflight_landed=None, launch_method_id=None, departure_location=None, landing_location=None, num_landings=None, departure_time=None, landing_time=None, towplane_id=None, towflight_mode=None, towflight_landing_location=None, towflight_landing_time=None, towpilot_id=None, pilot_last_name=None, pilot_first_name=None, copilot_last_name=None, copilot_first_name=None, towpilot_last_name=None, towpilot_first_name=None, comments=None, accounting_notes=None)

Representation of a flight in the startkladde database

Implements a single record in the Startkladde flights table. Each member represents the value of the column with the same name and type.

Parameters:
  • id (int) – ID of this record in table flights.
  • plane_id (int) – ID of Airplane record in table planes (ref. Airplane Record)
  • pilot_id (int) – ID of Pilot record for the pilot in command (or student for two seated training) in table people (ref. Pilot Record).
  • copilot_id (int) – ID of Pilot record for the copilot (or instructor in two seated training) in table people (ref. Pilot Record).
  • type (str) –

    Flight type. One of

    • normal‘ (normal flight)
    • training_1‘ (one seated training)
    • training_2‘ (two seated training)
    • guest_external‘ (guest flight)
    • guest_private‘ (private guest flight)
  • mode (str) –

    Flight mode. One of

    • local
    • inbound
    • outbound
  • departed (int) – 1 if flight is departed, 0 otherwise.
  • landed (int) – 1 if flight is landed, 0 otherwise.
  • towflight_landed (int) – 1 if towflight landed, 0 otherwise.
  • launch_method_id (int) – ID of applicable LaunchMethod record in table launch_methods (ref. Launch Method Record)
  • location (departure) – Departure location
  • landing_location (str) – Landing location
  • num_landings (int) – Number of landings
  • departure_time (datetime) – Departure time
  • landing_time (datetime) – Landing time
  • towplane_id (int) – ID of Airplane record for towplane in table planes (ref. Airplane Record).
  • towflight_mode (int) – Mode of towflight. Same values as in mode
  • towflight_landing_location (str) – Location of tow flight landing
  • towflight_landing_time (datetime) – Landing time of tow plane
  • towpilot_id – ID of Pilot record for the towpilot in table people (ref. Pilot Record).
  • pilot_last_name (str) – Deprecated. Should be None.
  • pilot_first_name (str) – Deprecated. Should be None.
  • copilot_last_name (str) – Deprecated. Should be None.
  • copilot_first_name (str) – Deprecated. Should be None.
  • towpilot_last_name (str) – Deprecated. Should be None.
  • towpilot_first_name (str) – Deprecated. Should be None.
  • comments (str) – Eventual comments
  • accounting_notes (str) – Eventual accounting notes
__lt__(other)

Compare two flights by their respective departure times

Parameters:other (Flight) – Instance to compare self to
Returns:True if and only if self.departure_time < other.departure_time
__str__()

Convert instance to string

Returns:departure_time departure_location
departureTime(format=None)

Get departure time as string.

Parameters:format (str) – Output format (in strftime notation). Defaults to TIME_FORMAT.
Returns:Departure time as string in given format for local and outbound flights. Departure location for inbound flights.
duration()

Get flight time

Returns:Flight time as timedelta object
landingTime(format=None)

Get landing time as string.

Parameters:format (str) – Output format (in strftime notation). Defaults to TIME_FORMAT.
Returns:Landing time as string in given format for local and inbound flights. Landing location for outbound flights.
pic()

Get pilot in command

Returns:ID of pilot in command
similar(other)

Check if two flights are conflicting.

Two flights are similar, if and only if their flight times overlap and either pilot and/or plane and/or copilot are identical.

Parameters:other (Flight) – flight to check current instance against
Returns:True if and only if self and other are similar
static tableName()

Get name of MySQL table, where this data type is used

Returns:‘flights
update()

Update members departed, landed and towflight_landed

Sets members self.departed, self.landed and self.towflight_landed from the information provided through landing_time, departure_time and towflight_landing_time

Constants

pysk.db.model.flight.TIME_FORMAT = '%Y-%m-%d %H:%M'

Default time format used for string IO