API

Module contents

class clickhouse_pool.ChPool(**kwargs)[source]

Bases: object

A ChPool is a pool of connections (Clients) to a ClickhouseServer.

connections_min

minimum number of connections to keep open

Type:

int

connections_max

maximum number of connections allowed open

Type:

int

closed

if closed the pool has no connections and cannot be used

Type:

bool

cleanup()[source]

Close all open connections in the pool.

This method loops through eveery client and calls disconnect.

get_client(key: str = None) Generator[Client, None, None][source]

A clean way to grab a client via a contextmanager.

Parameters:

key – If known, the key of the client to grab.

Yields:

Client – a clickhouse-driver client

pull(key: str = None) Client[source]

Get an available client from the pool.

Parameters:

key – If known, the key of the client you would like.

Returns:

A clickhouse-driver client.

push(client: Client = None, key: str = None, close: bool = False)[source]

Return a client to the pool for reuse.

Parameters:
  • client – The client to return.

  • key – If known, the key of the client.

  • close – Close the client instead of adding back to pool.