28 lines
694 B
Python
28 lines
694 B
Python
"""PostgreSQL execution operations used by the direct DWH adapter."""
|
|
|
|
from sqlalchemy import Engine
|
|
|
|
from tht.execute import (
|
|
ExecResult,
|
|
PlanSummary,
|
|
explain as _explain,
|
|
require_positive_int,
|
|
run_controlled,
|
|
)
|
|
|
|
DEFAULT_TIMEOUT_MS = 30_000
|
|
|
|
|
|
def run_query(engine: Engine, sql: str, *, limit: int, timeout_ms: int = DEFAULT_TIMEOUT_MS) -> ExecResult:
|
|
limit = require_positive_int(limit, name="limit")
|
|
return run_controlled(
|
|
engine,
|
|
sql,
|
|
limit=limit,
|
|
timeout_ms=timeout_ms,
|
|
)
|
|
|
|
|
|
def explain(engine: Engine, sql: str, *, timeout_ms: int = DEFAULT_TIMEOUT_MS) -> PlanSummary:
|
|
return _explain(engine, sql, timeout_ms=timeout_ms)
|