def test_iteration_io_in() -> None: open('/tmp/pyck_test_iteration_1', 'wb').write(b'hello\n') gen_in = iteration.stream_in(open('/tmp/pyck_test_iteration_1', 'rb')) assert list(gen_in) == [b'hello\n'] # TODO: test pipe_in open('/tmp/pyck_test_iteration_2', 'wb').write(b'hello\n') gen_in = iteration.file_in('/tmp/pyck_test_iteration_2') assert list(gen_in) == [b'hello\n']
def test_session_file() -> None: local_session = ck.LocalSession() local_session.query('drop table if exists pyck_test') local_session.query('create table pyck_test (x String) engine = Memory') open('/tmp/pyck_test_session_1', 'wb').write(b'hello\nworld\n') local_session.query('insert into pyck_test format TSV', gen_in=iteration.file_in('/tmp/pyck_test_session_1')) open('/tmp/pyck_test_session_2', 'wb').write(b'') local_session.query('select * from pyck_test format TSV', gen_out=iteration.file_out('/tmp/pyck_test_session_2')) assert open('/tmp/pyck_test_session_2', 'rb').read() == b'hello\nworld\n' local_session.query('drop table pyck_test')
def query_file_async( self, query: str, path_in: typing.Optional[str] = None, path_out: typing.Optional[str] = None, method: typing.Optional[typing_extensions.Literal['tcp', 'http', 'ssh']] = None, settings: typing.Optional[typing.Dict[str, str]] = None ) -> typing.Callable[[], None]: if path_in is None: gen_in = iteration.empty_in() else: gen_in = iteration.file_in(path_in) if path_out is None: gen_out = iteration.empty_out() else: gen_out = iteration.file_out(path_out) return self._run(query, gen_in, gen_out, method, settings)
def test_iteration_file_in() -> None: open('/tmp/pyck_test_iteration_2', 'wb').write(b'hello\n') gen_in = iteration.file_in('/tmp/pyck_test_iteration_2') assert list(gen_in) == [b'hello\n']