fix(core): restore adapter command behavior

This commit is contained in:
2026-07-11 21:04:53 +02:00
parent a35efa16de
commit 45d57756aa
7 changed files with 141 additions and 29 deletions
+4 -2
View File
@@ -1,7 +1,7 @@
"""Direct PostgreSQL implementation of the DWH port."""
from tht.config import DatabaseConfig
from sqlalchemy.exc import SQLAlchemyError
from sqlalchemy.exc import OperationalError, SQLAlchemyError
from tht.db import execute, sampling
from tht.db.connection import can_create_in_schema, make_engine, ping, writable_tables
@@ -22,8 +22,10 @@ class PostgresDwhAdapter:
def health(self) -> DwhHealth:
try:
ping(self._engine)
except OperationalError as exc:
return DwhHealth(ok=False, detail=str(exc.orig), error_kind="connection")
except SQLAlchemyError as exc:
return DwhHealth(ok=False, detail=str(exc))
return DwhHealth(ok=False, detail=str(exc), error_kind="connection")
writable = tuple(writable_tables(self._engine, self._config.db_schema))
can_create = can_create_in_schema(self._engine, self._config.db_schema)
return DwhHealth(ok=True, database=self._config.database, schema=self._config.db_schema,
+3 -2
View File
@@ -21,11 +21,12 @@ class ThothRestDwhAdapter:
try:
result = self._client.ping()
except RestError as exc:
return DwhHealth(ok=False, detail=str(exc))
return DwhHealth(ok=False, detail=str(exc), error_kind="connection")
ok = bool(result.get("db_connected") and result.get("schema_accessible"))
return DwhHealth(ok=ok, detail=None if ok else str(result),
database=self._database.database, schema=self._database.db_schema,
endpoint=self._client.cfg.base_url, read_only=True)
endpoint=self._client.cfg.base_url, read_only=True,
error_kind=None if ok else "inaccessible")
def introspect(self) -> PhysicalSchema:
return introspect_rest(