I have these libraries installed:
JavaScript
x
3
1
testcontainers==2.5
2
clickhouse-driver==0.1.0
3
This code:
JavaScript
1
16
16
1
from testcontainers.core.generic import GenericContainer
2
from clickhouse_driver import Client
3
4
5
def test_docker_run_clickhouse():
6
ch_container = GenericContainer("yandex/clickhouse-server")
7
ch_container.with_bind_ports(9000, 9000)
8
with ch_container as ch:
9
10
client = Client(host='localhost')
11
print(client.execute("SHOW TABLES"))
12
13
14
if __name__ == '__main__':
15
test_docker_run_clickhouse()
16
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?
Advertisement
Answer
It takes some time to run a container. Add a time delay before executing operations.
JavaScript
1
6
1
import time
2
with ch_container as ch:
3
time.sleep(3)
4
client = Client(host='localhost')
5
print(client.execute("SHOW TABLES"))
6