Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NL2SQL

Ask a question in plain English, get a plain-English answer — from any database connected through Trino (PostgreSQL, MongoDB, MySQL, and more). The app finds the relevant tables, writes one SQL query, runs it, and turns the result into an answer.

Stack

  • Trino — query engine every database connects through
  • Qdrant — vector store for searchable schema descriptions
  • Ollama — generates embeddings for Qdrant
  • An LLM via a LiteLLM proxy (or any OpenAI-compatible endpoint)
  • Upstash Redis (optional) — session history/memory; falls back to a local JSON file

Setup

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env   # fill in your Trino, Qdrant, Ollama, and LLM details

Adding a database

If Trino can connect to it (Postgres, MongoDB, MySQL, Snowflake, and most others):

  1. Add it to Trino's catalog configuration.
  2. Add its catalog name to TRINO_CATALOGS in .env.
  3. Run python main.py --ingest --force.

If it's not something Trino can connect to (a file upload, a custom API), write a plugin:

  1. Copy app/tools/plugin_template.py to app/tools/<yourname>_tool.py.
  2. Fill in its name, description, tool_schema(), and execute().
  3. Register it in app/tools/registry.py.

Run

python main.py --ingest     # load your database's structure (once, or whenever it changes)
python main.py               # ask questions in the terminal
uvicorn app.api:app --reload # or as a web app at http://localhost:8000

About

Ask a question in plain English, get a plain-English answer — from any database connected through Trino (PostgreSQL, MongoDB, MySQL, and more). The app finds the relevant tables, writes one SQL query, runs it, and turns the result into an answer.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages