File size: 548 Bytes
5dd1bb4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""Validation helpers for synthetic database variants."""

from __future__ import annotations

import sqlite3


def validate_gold_sql(
    db_path: str,
    gold_sql: str,
    timeout: float = 5.0,
) -> tuple[bool, str | None]:
    """Run gold SQL and report whether it returns a non-empty result set."""

    with sqlite3.connect(db_path, timeout=timeout) as connection:
        cursor = connection.cursor()
        cursor.execute(gold_sql)
        rows = cursor.fetchall()

    if not rows:
        return False, None

    return True, str(rows)