File size: 713 Bytes
efc0c0a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | """DbExecutor — runs compiled SQL on a user's external DB.
Pipeline:
IR → SqlCompiler → SQL string + params
↓
sqlglot validation (SELECT-only, whitelist tables/columns, LIMIT enforced)
↓
asyncpg / pymysql in read-only transaction with timeout (30s)
↓
QueryResult
"""
from ...catalog.models import Catalog
from ..compiler.sql import SqlCompiler
from ..ir.models import QueryIR
from .base import BaseExecutor, QueryResult
class DbExecutor(BaseExecutor):
def __init__(self, catalog: Catalog) -> None:
self._catalog = catalog
self._compiler = SqlCompiler(catalog)
async def run(self, ir: QueryIR) -> QueryResult:
raise NotImplementedError
|