From 9d025865e17f554d74ae0e17f340bf781207856c Mon Sep 17 00:00:00 2001 From: Simon Chen <1020359403@qq.com> Date: Thu, 4 Jul 2024 03:42:29 +0000 Subject: [PATCH] Fix dbapi error attribute --- clickhouse_sqlalchemy/drivers/asynch/connector.py | 4 +--- clickhouse_sqlalchemy/drivers/http/connector.py | 9 +-------- clickhouse_sqlalchemy/drivers/native/connector.py | 9 +-------- 3 files changed, 3 insertions(+), 19 deletions(-) diff --git a/clickhouse_sqlalchemy/drivers/asynch/connector.py b/clickhouse_sqlalchemy/drivers/asynch/connector.py index c0be3d5c..7e44341a 100644 --- a/clickhouse_sqlalchemy/drivers/asynch/connector.py +++ b/clickhouse_sqlalchemy/drivers/asynch/connector.py @@ -114,10 +114,8 @@ def __init__(self, asynch): self.paramstyle = 'pyformat' self._init_dbapi_attributes() - class Error(Exception): - pass - def _init_dbapi_attributes(self): + self.Error = self.asynch.errors.ClickHouseException for name in ( 'ServerException', 'UnexpectedPacketFromServerError', diff --git a/clickhouse_sqlalchemy/drivers/http/connector.py b/clickhouse_sqlalchemy/drivers/http/connector.py index 29bf9b49..4121bc55 100644 --- a/clickhouse_sqlalchemy/drivers/http/connector.py +++ b/clickhouse_sqlalchemy/drivers/http/connector.py @@ -9,14 +9,7 @@ threadsafety = 2 # Python extended format codes, e.g. ...WHERE name=%(name)s paramstyle = 'pyformat' - - -class Error(Exception): - """ - Exception that is the base class of all other error exceptions. - You can use this to catch all errors with one single except statement. - """ - pass +Error = Exception def connect(*args, **kwargs): diff --git a/clickhouse_sqlalchemy/drivers/native/connector.py b/clickhouse_sqlalchemy/drivers/native/connector.py index 01481efa..75b56fee 100644 --- a/clickhouse_sqlalchemy/drivers/native/connector.py +++ b/clickhouse_sqlalchemy/drivers/native/connector.py @@ -11,14 +11,7 @@ threadsafety = 2 # Python extended format codes, e.g. ...WHERE name=%(name)s paramstyle = 'pyformat' - - -class Error(Exception): - """ - Exception that is the base class of all other error exceptions. - You can use this to catch all errors with one single except statement. - """ - pass +Error = DatabaseException def connect(*args, **kwargs):