This Python package provides functions to convert natural language to SQL queries using a pre-trained language model.
Project description
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:
pip install tabqa
Quick Start
from tabqa import sql_model, generate_schema
# Define the natural language question
question = "Count Number of 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 :
- model_name: str = 'defog/sqlcoder-7b',
- cache_dir: str = './',
- device_map: str = 'auto',
- trust_remote_code: bool = True,
- torch_dtype: torch.dtype = torch.float16,
- use_cache: bool = True,
- force_download: bool = False,
- resume_download: bool = False,
- output_loading_info: bool = False,
- local_files_only: bool = False,
Model available :
- defog/sqlcoder-7b (lowest Accuracy)
- defog/sqlcoder-34b-alpha (Medium Accuracy)
- 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
- Import the necessary functions from
tabqa. - Define your natural language question.
- Provide the path to the SQL file containing your database schema.
- Initialize the SQL model.
- Use
generate_schema()function to convert the natural language question into an SQL query. - 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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tabqa-0.1.3.tar.gz.
File metadata
- Download URL: tabqa-0.1.3.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2202bd3a97fc7e411af3c11f2d019e3f4dc9f9ac6a22050dbf50e792ff5f20d0
|
|
| MD5 |
78ebbb8c13ddc761f49a4af7c47cf7cb
|
|
| BLAKE2b-256 |
368c08fbce273c947f7ff64b5161cede602245b8e1fbeee370db071b9cd3f0d3
|
File details
Details for the file tabqa-0.1.3-py3-none-any.whl.
File metadata
- Download URL: tabqa-0.1.3-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fec8bdb4e0296d63d67d0a73a4544a6b0ccdb1716eecbe603ed2be838c2cb69d
|
|
| MD5 |
d6cc4cf5d9ff652c0590588fb1a5f41a
|
|
| BLAKE2b-256 |
6ca98d4e12cb365459dd64b4df663cdb42d2e3a635b1c7720545519a3d3a2dbc
|