How to use the pyexasol.script_output.ExaScriptOutputProcess function in pyexasol

To help you get started, we’ve selected a few pyexasol examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github badoo / pyexasol / pyexasol / __main__.py View on Github external
args = parser.parse_args()

if args.command == 'script_output':
    from .script_output import ExaScriptOutputProcess

    obj = ExaScriptOutputProcess(args.host, args.port, args.output_dir, args.ppid)
    obj.init_server_script_mode()

    obj.send_output_address()
    obj.handle_requests_script_mode()

elif args.command == 'script_debug':
    from .script_output import ExaScriptOutputProcess

    obj = ExaScriptOutputProcess(args.host, args.port)
    obj.init_server_debug_mode()

    output_address = obj.get_output_address()
    print(f"ALTER SESSION SET SCRIPT_OUTPUT_ADDRESS = '{output_address}';", flush=True)

    obj.handle_requests_debug_mode()

elif args.command == 'version':
    from .version import __version__
    print(f'PyEXASOL {__version__}')
github badoo / pyexasol / pyexasol / connection.py View on Github external
def execute_udf_output(self, query, query_params=None):
        """
        Execute SQL query with UDF script, capture output
        Return ExaStatement object and list of Path-objects for script output log files

        Exasol should be able to open connection to the host where current script is running
        """

        self._udf_output_count += 1
        output_dir = utils.get_output_dir_for_statement(self.options['udf_output_dir'],
                                                        self.session_id(),
                                                        self._udf_output_count)

        script_output = ExaScriptOutputProcess(self.options['udf_output_bind_address'][0],
                                               self.options['udf_output_bind_address'][1],
                                               output_dir)
        script_output.start()

        # This option is useful to get around complex network setups, like Exasol running in Docker containers
        if self.options['udf_output_connect_address']:
            address = f"{self.options['udf_output_connect_address'][0]}:{self.options['udf_output_connect_address'][1]}"
        else:
            address = script_output.get_output_address()

        self.execute("ALTER SESSION SET SCRIPT_OUTPUT_ADDRESS = {address}", {'address': address})

        try:
            stmt = self.execute(query, query_params)
            script_output.join()
        except ExaQueryError:
github badoo / pyexasol / pyexasol / __main__.py View on Github external
subp.add_argument('--output-dir', help='Directory to write enumerated log files, one file per VM')
subp.add_argument('--ppid', help='PID of parent process', default=None)


subp = subparsers.add_parser('script_debug', help='Run script output server for debugging and display output of ONE VM')
subp.add_argument('--host', default='0.0.0.0', help='Specific address to bind TCPServer (default: 0.0.0.0)')
subp.add_argument('--port', default=0, help='Specific port to bind TCPServer (default: random port)', type=int)

subp = subparsers.add_parser('version', help='Show PyEXASOL version')

args = parser.parse_args()

if args.command == 'script_output':
    from .script_output import ExaScriptOutputProcess

    obj = ExaScriptOutputProcess(args.host, args.port, args.output_dir, args.ppid)
    obj.init_server_script_mode()

    obj.send_output_address()
    obj.handle_requests_script_mode()

elif args.command == 'script_debug':
    from .script_output import ExaScriptOutputProcess

    obj = ExaScriptOutputProcess(args.host, args.port)
    obj.init_server_debug_mode()

    output_address = obj.get_output_address()
    print(f"ALTER SESSION SET SCRIPT_OUTPUT_ADDRESS = '{output_address}';", flush=True)

    obj.handle_requests_debug_mode()