from gppylib.commands.base import Command, get_results class MyCommand(Command): def __init__(self, conn, query): Command.__init__(self, "MyCommand") self.conn = conn self.query = query def execute(self): result = self.conn.execute_query(self.query) return result cmd = MyCommand(my_conn, "SELECT * FROM my_table") result = cmd.run() my_results = get_results(result)
from gppylib.commands.base import Command, get_results class MyCommand(Command): def __init__(self, cmd): Command.__init__(self, "MyCommand") self.cmd = cmd def execute(self): result = self.execute_command(self.cmd) return result cmd = MyCommand("ls -la") result = cmd.run() my_results = get_results(result)In this example, we create a custom command called MyCommand that runs a shell command and returns the output. We then run the command and retrieve the output using the get_results command.