Skip to main content

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 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.

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

tabqa-0.1.2.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tabqa-0.1.2-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file tabqa-0.1.2.tar.gz.

File metadata

  • Download URL: tabqa-0.1.2.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

Hashes for tabqa-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ba44993b156cdb91a2100c9a9fc24e1119ee465469628ddd6d7fdd7373a9bce8
MD5 91b1e179fc0cfc81f91f509fb0706fc2
BLAKE2b-256 817e6cdaaf88d57b658cdddb9c3e12e56d0937ca8ed0a72d6784fd865e0ad3c6

See more details on using hashes here.

File details

Details for the file tabqa-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: tabqa-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.8

File hashes

Hashes for tabqa-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 605f4e19d3033e0bc3b3efc65c7644fb3dd9b0757fabf107ccfd448a3229b7f7
MD5 f3316bff6834fbe1ebd66078d127a334
BLAKE2b-256 cd5b687264d75fbe580599b5ffcb04b16dfbb7da9bbbf18b9c9c5079bb80d4b6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page