23 lines
610 B
Python
23 lines
610 B
Python
"""PostgreSQL execution operations used by the direct DWH adapter."""
|
|
|
|
from sqlalchemy import Engine
|
|
|
|
from tht.execute import ExecResult, PlanSummary, explain as _explain, run_controlled
|
|
|
|
DEFAULT_TIMEOUT_MS = 30_000
|
|
|
|
|
|
def run_query(engine: Engine, sql: str, *, limit: int) -> ExecResult:
|
|
if limit <= 0:
|
|
raise ValueError("limit must be a positive integer")
|
|
return run_controlled(
|
|
engine,
|
|
sql,
|
|
limit=limit,
|
|
timeout_ms=DEFAULT_TIMEOUT_MS,
|
|
)
|
|
|
|
|
|
def explain(engine: Engine, sql: str) -> PlanSummary:
|
|
return _explain(engine, sql, timeout_ms=DEFAULT_TIMEOUT_MS)
|