4

I have these libraries installed:

testcontainers==2.5
clickhouse-driver==0.1.0

This code:

from testcontainers.core.generic import GenericContainer
from clickhouse_driver import Client


def test_docker_run_clickhouse():
    ch_container = GenericContainer("yandex/clickhouse-server")
    ch_container.with_bind_ports(9000, 9000)
    with ch_container as ch:

        client = Client(host='localhost')
        print(client.execute("SHOW TABLES"))


if __name__ == '__main__':
    test_docker_run_clickhouse()

I am trying to get a generic container with clickhouse DB running.

But it gives me: EOFError: Unexpected EOF while reading bytes.

I am using Python 3.5.2. How to fix this?

techkuz
  • 3,608
  • 5
  • 34
  • 62

1 Answers1

4

It takes some time to run a container. Add a time delay before executing operations.

import time
with ch_container as ch:
        time.sleep(3)
        client = Client(host='localhost')
        print(client.execute("SHOW TABLES"))
techkuz
  • 3,608
  • 5
  • 34
  • 62