def add_location(self, location):
    if (self.conn == None):
        raise Exception('DBLogger requires active connection status.')
    (lon, lat, alt) = location
    self.conn.execute(('SELECT loc_id FROM locations WHERE %s AND %s AND %s LIMIT 1' % ((("longitude = '%f'" % lon) if (lon != None) else 'longitude IS NULL'), (("latitude = '%f'" % lat) if (lat != None) else 'latitude IS NULL'), (("elevation = '%f'" % alt) if (alt != None) else 'elevation IS NULL'))))
    res = self.conn.fetchone()
    if (res != None):
        return res
    else:
        self.conn.execute(('INSERT INTO locations SET %s, %s, %s' % ((("longitude = '%f'" % lon) if (lon != None) else 'longitude = NULL'), (("latitude = '%f'" % lat) if (lat != None) else 'latitude = NULL'), (("elevation = '%f'" % alt) if (alt != None) else 'elevation = NULL'))))
        if (self.conn.rowcount != 1):
            raise Exception('Location insert did not succeed.')
        self.db.commit()
        return self.conn.lastrowid
def add_location(self, location):
    if (self.conn == None):
        raise Exception('DBLogger requires active connection status.')
    (lon, lat, alt) = location
    self.conn.execute(('SELECT loc_id FROM locations WHERE %s AND %s AND %s LIMIT 1' % ((("longitude = '%f'" % lon) if (lon != None) else 'longitude IS NULL'), (("latitude = '%f'" % lat) if (lat != None) else 'latitude IS NULL'), (("elevation = '%f'" % alt) if (alt != None) else 'elevation IS NULL'))))
    res = self.conn.fetchone()
    if (res != None):
        return res
    else:
        self.conn.execute(('INSERT INTO locations SET %s, %s, %s' % ((("longitude = '%f'" % lon) if (lon != None) else 'longitude = NULL'), (("latitude = '%f'" % lat) if (lat != None) else 'latitude = NULL'), (("elevation = '%f'" % alt) if (alt != None) else 'elevation = NULL'))))
        if (self.conn.rowcount != 1):
            raise Exception('Location insert did not succeed.')
        self.db.commit()
        return self.conn.lastrowid