Skip to content

Commit 90bfcd9

Browse files
mdesmetebyhr
authored andcommitted
Fix for dbapi exceptions in sqlalchemy
As `TrinoUserError` is now a dbapi exception, is converted into `sqlalchemy.exc.ProgrammingError`.
1 parent a71b8bc commit 90bfcd9

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

trino/sqlalchemy/dialect.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from trino import dbapi as trino_dbapi, logging
2323
from trino.auth import BasicAuthentication, CertificateAuthentication, JWTAuthentication
2424
from trino.dbapi import Cursor
25-
from trino.exceptions import TrinoUserError
2625
from trino.sqlalchemy import compiler, datatype, error
2726

2827
logger = logging.get_logger(__name__)
@@ -320,8 +319,8 @@ def _get_server_version_info(self, connection: Connection) -> Any:
320319
res = connection.execute(sql.text(query))
321320
version = res.scalar()
322321
return tuple([version])
323-
except TrinoUserError as e:
324-
logger.debug(f"Failed to get server version: {e.message}")
322+
except exc.ProgrammingError as e:
323+
logger.debug(f"Failed to get server version: {e.orig.message}")
325324
return None
326325

327326
def _get_default_schema_name(self, connection: Connection) -> Optional[str]:

0 commit comments

Comments
 (0)