def load_tunnels(self): # Clear the tunnels list form the collection self.tunnels.clear_tunnels() # Create the DBConnection database = DBConnection() # Create the SQL sql = "SELECT * FROM tunnels WHERE id_connection = {}" # Bind the value sql = sql.format(self.id) # Execute the query rows = database.select_query(sql) # Set the attrs for row in rows: tunnel = Tunnel() tunnel.id = row['id_tunnel'] tunnel.id_connection = self.id tunnel.local_port = row['local_port'] tunnel.address = row['address'] tunnel.remote_port = row['remote_port'] # Add on Tunnels self.tunnels.add_tunnel(tunnel)
def load_tunnels(self, id_connection): # Reset the List self.tunnels = [] # Create the SQL sql = "select * from tunnels where id_connection = {}" sql = sql.format(id_connection) # Execute the sql results = self.dbconnection.select_query(sql) # Create a model for every tunnel for row in results: # Create new Connection tunnel = Tunnel() tunnel.id = 0 if row['id_tunnel'] is None else row['id_tunnel'] tunnel.id_connection = 0 if row['id_connection'] is None else row['id_connection'] tunnel.local_port = row['local_port'] tunnel.address = row['address'] tunnel.remote_port = row['remote_port'] # Add to the list self.tunnels.append(tunnel)