Skip to content

sayyidka/sql-speaker-api

Repository files navigation


Logo

SQL Speaker

A Text-to-SQL application to query Snowflake database using natural language

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. User Interface
  5. License
  6. Contact

About The Project

Presentation

SQL Speaker is an API that converts natural language text into SQL statements for querying a Snowflake database. The API is designed to simplify database interactions, making it accessible to users without extensive SQL knowledge (Business stakeholders, Managers). This enables quick and easy data retrieval from a database by simply describing the data request in plain English.

(back to top)

Architecture

(back to top)

Getting Started

This app can be installed running Docker (recommended) or locally.

Prerequisites

Installation

  1. On your Snowflake account, if you have not any database created yet, create a database and schema, and copy/paste both the create.sql then insert.sql scripts in order to have data to query.
  2. Rename the .env.example file to .env and fill the variables with your values.
  3. Run Docker on your laptop
  4. Run docker build -t sql-speaker .. It will build the API's Docker image.
  5. Run start.sh file. It will run a container using the previous built image.

(back to top)

Usage

The API is available on port 5000 with endpoint /ask. A typical request should be as the following :

{
  "query": "What is the total sales revenue for each product category ?",
  "sql_in_answer": false,
  "sql_mode": false
}
  • Set sql_in_answer to true to include the query generated by OpenAI API in the response.
  • Set sql_mode to true to make a plain SQL query. OpenAI API will not be called and the query will be directly addressed to Snowflake.

(back to top)

UI

A web UI is available here : https://github.com/sayyidka/sql-speaker-chatbot

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Wadieh Karbal - https://www.linkedin.com/in/wadieh-k-865b40181/

(back to top)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published