Metadata-Version: 2.1
Name: tabqa
Version: 0.1.2
Summary: This Python package provides functions to convert natural language to SQL queries using a pre-trained language model.
Author: Ketan More
Description-Content-Type: text/markdown
Requires-Dist: torch
Requires-Dist: transformers
Requires-Dist: bitsandbytes
Requires-Dist: accelerate
Requires-Dist: sqlparse

# tabqa: Natural Language to SQL Query Converter

## Overview
This Python library enables the conversion of natural language queries into SQL queries. It simplifies the process of querying databases by allowing users to express their queries in everyday language.

## Installation
You can install the package via pip:

```bash
pip install tabqa
```

## Quick Start
```python
from tabqa import sql_model, generate_schema

# Define the natural language question
question = "Count Number products"

# Path to the SQL file containing the database schema
file_path = "schema.sql"

# Initialize the SQL model
model = sql_model()

# Generate the SQL schema from the natural language question
result = generate_schema(question, file_path, model)

# Print the generated SQL query
print(result)
```

## Parameters for `sql_model` function :

1. model_name: str = 'defog/sqlcoder-7b',
2. cache_dir: str = './',
3. device_map: str = 'auto',
4. trust_remote_code: bool = True,
5. torch_dtype: torch.dtype = torch.float16,
6. use_cache: bool = True,
7. force_download: bool = False,
8. resume_download: bool = False,
9. output_loading_info: bool = False,
10. local_files_only: bool = False,

## Model available :

1. defog/sqlcoder-7b (lowest Accuracy)
2. defog/sqlcoder-34b-alpha (Medium Accuracy)
3. defog/sqlcoder-70b-alpha (Highest Accuracy)

**Warning:** 'defog/sqlcoder-34b-alpha' and 'defog/sqlcoder-70b-alpha' demand high GPU and RAM resources. Please don't use on local machines.

## How to Use
1. Import the necessary functions from `tabqa`.
2. Define your natural language question.
3. Provide the path to the SQL file containing your database schema.
4. Initialize the SQL model.
5. Use `generate_schema()` function to convert the natural language question into an SQL query.
6. Print or use the generated SQL query as needed.

## Contribution
Contributions are welcome! If you encounter any issues or have suggestions for improvements, feel free to open an issue or submit a pull request.

## License
This project is licensed under the [MIT License](https://opensource.org/license/mit).
