Metadata-Version: 2.4
Name: SQaLe
Version: 0.1.2
Summary: Deserialize the SQaLe dataset into populated SQLite databases.
License: MIT License
        
        Copyright (c) 2026 TRL Lab
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pandas
Requires-Dist: tqdm
Requires-Dist: pyarrow
Requires-Dist: datasets
Dynamic: license-file

# SQaLe

A Python utility for deserializing the [SQaLe dataset](https://huggingface.co/datasets/trl-lab/SQaLe_2) into populated SQLite databases.

Each unique schema in the dataset is materialized as a `.db` file and populated with the synthetic row data stored alongside it — ready to use for SQL benchmarking, evaluation, or development.

## Installation

```bash
pip install SQaLe
```

## Usage

### CLI

```bash
# Download and deserialize all schemas
sqale-extract --output ./dbs

# Limit to the first 100 unique schemas
sqale-extract --output ./dbs --limit 100
```

### Python API

```python
from sqale import deserialize_sqale

results = deserialize_sqale(
    file_path="trl-lab/SQaLe_2",  # HuggingFace repo ID or local path
    output_dir="./dbs",
    limit=100,  # optional
)

for r in results:
    print(r["db_path"], r["rows_per_table"])
```

The function returns a list of dicts with the following fields:

| Field | Description |
|---|---|
| `schema_id` | Original schema ID from the dataset |
| `db_path` | Absolute path to the created `.db` file |
| `tables` | List of table names found in the DDL |
| `rows_per_table` | Dict mapping table name → number of rows inserted |
| `error` | Error message if materialization failed, otherwise `None` |

### Loading from a local file

```python
results = deserialize_sqale(
    file_path="./data/train.parquet",
    output_dir="./dbs",
)
```

Supported local formats: `.parquet`, `.arrow`, or a directory containing either.

## Requirements

- Python ≥ 3.9
- `pandas`, `tqdm`, `pyarrow`, `datasets`

## License

See [LICENSE](LICENSE).
