Initialize SQL tester with database schemas and execution logic Args: tables_file: Path to JSON file containing database schemas databases_dir: Directory containing SQLite database files
(self,
tables_file: str = "tables.json",
databases_dir: str = "databases")
| 17 | """ |
| 18 | |
| 19 | def __init__(self, |
| 20 | tables_file: str = "tables.json", |
| 21 | databases_dir: str = "databases"): |
| 22 | """ |
| 23 | Initialize SQL tester with database schemas and execution logic |
| 24 | |
| 25 | Args: |
| 26 | tables_file: Path to JSON file containing database schemas |
| 27 | databases_dir: Directory containing SQLite database files |
| 28 | """ |
| 29 | self.tables_file = tables_file |
| 30 | self.databases_dir = databases_dir |
| 31 | |
| 32 | # Load database schemas from tables file |
| 33 | if os.path.exists(tables_file): |
| 34 | with open(tables_file, 'r', encoding='utf-8') as f: |
| 35 | self.tables = {db['db_id']: db for db in json.load(f)} |
| 36 | else: |
| 37 | self.tables = {} |
| 38 | |
| 39 | def extract_dbid(self, question: str) -> str: |
| 40 | """Extract database ID from question. |