def positions_parsing(self, dictionary_object): """ A new position is created and put in the database, returns KeyError if an attribute is missing :param dictionary_object: The to be parsed dictionary """ try: positions = Positions() positions.create( datetime=dictionary_object['datetime'], unitid=dictionary_object['unitid'], rdx=dictionary_object['rdx'], rdy=dictionary_object['rdy'], speed=dictionary_object['speed'], course=dictionary_object['course'], numsatallites=dictionary_object['numsatallites'], hdop=dictionary_object['hdop'], quality=dictionary_object['quality'] ) except KeyError: # print("Missing 1 or multiple attributes") return "Missing 1 or multiple attributes in positions" except peewee.IntegrityError: database.rollback() print("Duplicate")
def car_parsing(self, dictionary_object): """ A new car is created and put in the database, returns KeyError if an attribute is missing :param dictionary_object: The to be parsed dictionary """ try: car = Car() car.create( unitid=dictionary_object['unitid'] ) except KeyError: # print("Missing 1 or multiple attributes") return "Missing 1 or multiple attributes in car" except peewee.IntegrityError: database.rollback() print("Duplicate")
def connections_parsing(self, dictionary_object): """ A new connection is created and put in the database, returns KeyError if an attribute is missing :param dictionary_object: The to be parsed dictionary """ try: connection = Connections() connection.create( datetime=dictionary_object['datetime'], unitid=dictionary_object['unitid'], port=dictionary_object['port'], value=dictionary_object['value'] ) except KeyError: # print("Missing 1 or multiple attributes") return "Missing 1 or multiple attributes in connections" except peewee.IntegrityError: database.rollback() print("Duplicate")
def monitoring_parsing(self, dictionary_object): """ A new monitoring is created and put in the database, returns KeyError if an attribute is missing :param dictionary_object: The to be parsed dictionary """ try: monitoring = Monitoring() monitoring.create( unitid=dictionary_object['unitid'], begintime=dictionary_object['begintime'], endtime=dictionary_object['endtime'], type=dictionary_object['type'], min=dictionary_object['min'], max=dictionary_object['max'], sum=dictionary_object['sum'] ) except KeyError: # print("Missing 1 or multiple attributes") return "Missing 1 or multiple attributes in monitoring" except peewee.IntegrityError: database.rollback() print("Duplicate")