From da0351b0d32d04fed49854f07ef7f1e5c4c7cb98 Mon Sep 17 00:00:00 2001 From: Geoff Genz Date: Sat, 10 Sep 2022 14:59:20 -0600 Subject: [PATCH] Tweak test requirements (#42) --- CHANGELOG.md | 4 ++++ clickhouse_connect/driver/client.py | 2 +- clickhouse_connect/driver/httpclient.py | 4 +++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e25b6133..854783d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ * In the next minor release (0.3.0) the row_binary option for ClickHouse serialization will be removed. The performance is significantly lower than Native format and maintaining the option adds complexity with no corresponding benefit +### Release 0.2.7 2022-09-10 + +#### Improvement +* The HTTP client now raises an OperationalError instead of a DatabaseError when the HTTP status code is 429 (too many requests), 503 (service unavailable), or 504 (gateway timeout) to make it easier to determine if it is a retryable exception ### Release 0.2.6 2022-09-08 diff --git a/clickhouse_connect/driver/client.py b/clickhouse_connect/driver/client.py index dafbd1c1..6dec6864 100644 --- a/clickhouse_connect/driver/client.py +++ b/clickhouse_connect/driver/client.py @@ -397,7 +397,7 @@ def raw_insert(self, table: str, fmt: Optional[str] = None): """ Insert data already formatted in a bytes object - :param table: Table name (whether or not qualified with the database name + :param table: Table name (whether qualified with the database name or not) :param column_names: Sequence of column names :param insert_block: Binary or string data already in a recognized ClickHouse format :param settings: Optional dictionary of ClickHouse settings (key/string values) diff --git a/clickhouse_connect/driver/httpclient.py b/clickhouse_connect/driver/httpclient.py index ae376069..c692aea0 100644 --- a/clickhouse_connect/driver/httpclient.py +++ b/clickhouse_connect/driver/httpclient.py @@ -272,8 +272,10 @@ def _raw_request(self, err_msg = response.content.decode(errors='backslashreplace') logger.error(str(err_msg)) err_str = f':{err_str}\n {err_msg[0:240]}' - if attempts > retries or response.status_code not in (429, 503, 504): + if response.status_code not in (429, 503, 504): raise DatabaseError(err_str) + if attempts > retries: + raise OperationalError(err_str) def ping(self): """