Skip to main content

A CLI tool to generate SQL project boilerplate

Project description

Genshot SQL

Created by Pranav Verma

Genshot SQL is an AI-powered Python library that allows you to interact with a MySQL database using natural language. Instead of writing SQL queries manually, you can ask questions in plain English and receive results directly from your database.

The library uses Retrieval-Augmented Generation (RAG), FAISS, and Ollama to understand your database schema and generate accurate SQL queries.

Features

  • Chat with your MySQL database using natural language
  • Schema-aware SQL generation
  • FAISS-powered semantic schema retrieval
  • Local AI inference using Ollama
  • Read-only query generation (SELECT queries)
  • Fast and lightweight setup

How It Works

  1. Provide your database schema.
  2. The schema is embedded and indexed using FAISS.
  3. Ask questions in plain English.
  4. The AI retrieves the most relevant schema context.
  5. The LLM generates SQL.
  6. The query is executed on MySQL.
  7. Results are returned to the user.

Installation

pip install genshot-sql-pranav

Dependencies

Install the required Python packages:

pip install faiss-cpu mysql-connector-python numpy

Ollama Requirements

Install Ollama and pull the required model:

ollama pull llama3.2:3b

You will also need an embedding model:

ollama pull nomic-embed-text

Steps to Run

Step 1: Install the library Step 2: Install all the dependencies Step 3: Install ollama and pull llama3.2:3b model Step 4: Insert config data and schema in config.py Step 5: Run the file chat_with_database.py

python chat_with_database.py

Example conversation:

You: Show all employees in the IT department

SQL:
SELECT e.*
FROM employee e
INNER JOIN department d
ON e.department_id = d.id
WHERE d.name = 'IT';

Result:
...

Use Cases

  • Internal business analytics
  • Database exploration
  • Rapid SQL prototyping
  • Educational projects
  • AI-powered database assistants

Tech Stack

  • Python
  • MySQL
  • FAISS
  • NumPy
  • Ollama
  • Llama 3.2 3B
  • Retrieval-Augmented Generation (RAG)

License

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

genshot_sql_pranav-0.1.3.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

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

genshot_sql_pranav-0.1.3-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file genshot_sql_pranav-0.1.3.tar.gz.

File metadata

  • Download URL: genshot_sql_pranav-0.1.3.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for genshot_sql_pranav-0.1.3.tar.gz
Algorithm Hash digest
SHA256 560089c6f70921cfc7c166f8d02914369491380e942aedac60572c0bbdb88854
MD5 b4bbdaa14d02f8c9f1d798c092299aff
BLAKE2b-256 6cf1e241d20d1b8347267841850b2f1db1f598826a4a31f449265032bbee87d5

See more details on using hashes here.

File details

Details for the file genshot_sql_pranav-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for genshot_sql_pranav-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4a490d55d656d1282229a9194912e63268c2d9b086ff84fa984eadada1698c19
MD5 56bd5194450f6048ecd6ff019a662e7d
BLAKE2b-256 2fdf1fc820d86844e0f118b9fb45fd18e12f6ce06342ec1ee8dc97049e3bcaa4

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